/*      */ package dm.jdbc.dbaccess;
/*      */ 
/*      */ import com.sun.jna.Native;
/*      */ import com.sun.jna.Pointer;
/*      */ import com.sun.jna.ptr.IntByReference;
/*      */ import com.sun.jna.ptr.PointerByReference;
/*      */ import dm.jdbc.dataConvertion.Convertion;
/*      */ import dm.jdbc.desc.ColumnDesc;
/*      */ import dm.jdbc.desc.GlobalControlCfg;
/*      */ import dm.jdbc.desc.ParameterDesc;
/*      */ import dm.jdbc.driver.DmBinder;
/*      */ import dm.jdbc.driver.DmExternalCrypto;
/*      */ import dm.jdbc.driver.DmInputStreamBinder;
/*      */ import dm.jdbc.driver.DmNullBinder;
/*      */ import dm.jdbc.driver.DmOutParamBinder;
/*      */ import dm.jdbc.driver.DmReaderBinder;
/*      */ import dm.jdbc.driver.DmdbCSI;
/*      */ import dm.jdbc.driver.DmdbCallableStatement_bs;
/*      */ import dm.jdbc.driver.DmdbColumn;
/*      */ import dm.jdbc.driver.DmdbConnection_bs;
/*      */ import dm.jdbc.driver.DmdbInfo;
/*      */ import dm.jdbc.driver.DmdbLob;
/*      */ import dm.jdbc.driver.DmdbLobLocator;
/*      */ import dm.jdbc.driver.DmdbPreparedStatement_bs;
/*      */ import dm.jdbc.driver.DmdbResultSetCache;
/*      */ import dm.jdbc.driver.DmdbResultSetCache_h;
/*      */ import dm.jdbc.driver.DmdbResultSetCache_v;
/*      */ import dm.jdbc.driver.DmdbResultSet_bs;
/*      */ import dm.jdbc.driver.DmdbStatement_bs;
/*      */ import dm.jdbc.driver.DmdbType;
/*      */ import dm.jdbc.innerData.DmdbExecOpt;
/*      */ import dm.jdbc.util.StringUtil;
/*      */ import dm.jdbc.xa.DmdbXAException;
/*      */ import dm.jdbc.xa.DmdbXAResource;
/*      */ import dm.jdbc.xa.DmdbXid;
/*      */ import dm.sql.TypeDescriptor;
/*      */ import java.io.PrintStream;
/*      */ import java.io.UnsupportedEncodingException;
/*      */ import java.sql.Connection;
/*      */ import java.sql.SQLException;
/*      */ import java.sql.SQLWarning;
/*      */ import java.util.Properties;
/*      */ import java.util.ResourceBundle;
/*      */ import javax.transaction.xa.XAException;
/*      */ import javax.transaction.xa.Xid;
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ public class Request_Response
/*      */ {
/*      */   public static final void req_startup(DmMsgSend msg, DmdbConnection_bs conn, boolean toPrimary)
/*      */     throws SQLException
/*      */   {
/*   57 */     req_initMsg(msg);
/*      */     
/*      */ 
/*   60 */     msg.req_startup_set_encrypt_type(0);
/*      */     
/*   62 */     if (conn.isCompress()) {
/*   63 */       msg.req_startup_set_cmp_flag(2);
/*      */     } else {
/*   65 */       msg.req_startup_set_cmp_flag(0);
/*      */     }
/*      */     
/*   68 */     if (conn.isBdtaRS()) {
/*   69 */       msg.req_startup_set_rs_bdta_flag((byte)2);
/*      */     } else {
/*   71 */       msg.req_startup_set_rs_bdta_flag((byte)0);
/*      */     }
/*   73 */     if (GlobalControlCfg.getCommunicationEncrypt())
/*      */     {
/*   75 */       msg.req_startup_set_comm_enc_flag((byte)1);
/*   76 */       msg.req_startup_set_gen_keypair_flag((byte)1);
/*      */     }
/*      */     else
/*      */     {
/*   80 */       msg.req_startup_set_comm_enc_flag((byte)0);
/*   81 */       msg.req_startup_set_gen_keypair_flag((byte)0);
/*      */     }
/*      */     
/*      */ 
/*   85 */     int offset = 64;
/*   86 */     String str = DmdbType.getVersion();
/*      */     
/*      */ 
/*   89 */     byte[] buf = Convertion.getBytes(str, conn.getServerEncoding());
/*   90 */     offset += msg.setBytesWithLen4(buf, 0, offset, buf.length);
/*      */     
/*      */ 
/*      */ 
/*   94 */     byte flag = 0;
/*   95 */     String uKeyName = conn.getProperties().getProperty("uKeyName");
/*   96 */     if ((uKeyName != null) && (uKeyName.length() > 0))
/*      */     {
/*   98 */       DmExternalCrypto INSTANCE = (DmExternalCrypto)Native.loadLibrary(uKeyName, 
/*   99 */         DmExternalCrypto.class);
/*      */       
/*  101 */       flag = 1;
/*  102 */       offset += msg.setByte(flag, offset);
/*      */       
/*  104 */       conn.setUKeyFlag(true);
/*  105 */       boolean rv = false;
/*  106 */       byte[] cert = new byte['က'];
/*  107 */       int cert_len = 4096;
/*      */       
/*  109 */       PointerByReference pref = new PointerByReference();
/*  110 */       IntByReference iref = new IntByReference(100);
/*      */       
/*  112 */       rv = INSTANCE.crypto_get_name(pref, iref);
/*  113 */       if (!rv)
/*      */       {
/*  115 */         DBError.throwSQLException(6001);
/*      */       }
/*      */       
/*  118 */       Pointer p = pref.getValue();
/*  119 */       byte[] buffer = p.getByteArray(0L, iref.getValue());
/*      */       
/*  121 */       if (!uKeyName.equalsIgnoreCase(new String(buffer)))
/*      */       {
/*  123 */         DBError.throwSQLException(6001);
/*      */       }
/*      */       
/*  126 */       String uKeyPin = conn.getProperties().getProperty("uKeyPin");
/*      */       
/*  128 */       rv = INSTANCE.crypto_login(pref, uKeyPin.getBytes(), uKeyPin.length());
/*  129 */       if (!rv)
/*      */       {
/*  131 */         DBError.throwSQLException(6001);
/*      */       }
/*      */       
/*  134 */       iref = new IntByReference(4096);
/*  135 */       rv = INSTANCE.crypto_read_cert(p, cert, iref);
/*  136 */       if (!rv)
/*      */       {
/*  138 */         DBError.throwSQLException(6001);
/*      */       }
/*      */       
/*  141 */       cert_len = iref.getValue();
/*      */       
/*  143 */       buf = Convertion.getBytes(uKeyName, conn.getServerEncoding());
/*  144 */       offset += msg.setBytesWithLen4(buf, 0, offset, buf.length);
/*  145 */       offset += msg.setBytesWithLen4(cert, 0, offset, cert_len);
/*      */     }
/*      */     
/*  148 */     offset += msg.setByte(flag, offset);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  154 */     if (GlobalControlCfg.getCommunicationEncrypt())
/*      */     {
/*  156 */       byte[] clientPubKey = conn.getDbAccess().getClientPubKey(toPrimary);
/*  157 */       offset += msg.setBytesWithLen4(clientPubKey, 0, offset, 64);
/*      */     }
/*      */     
/*      */ 
/*  161 */     req_setCommonHead(msg, 0, (short)200, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */   public static final void resp_startup(DmMsgRecv recvMsg, DmdbConnection_bs conn, boolean toPrimary)
/*      */     throws SQLException
/*      */   {
/*  168 */     boolean pwd_encrypt = false;
/*  169 */     byte[] sessionKey = null;
/*  170 */     int msgEncryptType = -1;
/*  171 */     int msgCipherType = -1;
/*  172 */     int len = 0;
/*      */     
/*      */ 
/*  175 */     resp_startup_get_msghead(recvMsg, conn);
/*      */     
/*  177 */     resp_checkErr(recvMsg, conn);
/*      */     
/*  179 */     int comm_enc_flag = recvMsg.res_startup_get_comm_enc_flag();
/*  180 */     int gen_keypair_flag = recvMsg.res_startup_get_gen_keypair_flag();
/*      */     
/*  182 */     int offset = 64;
/*  183 */     offset += recvMsg.getErrlen();
/*      */     
/*      */ 
/*  186 */     len = (int)recvMsg.getInt(offset);
/*  187 */     offset += 4;
/*      */     
/*  189 */     conn.setDmServerVersion(recvMsg.getString(offset, len));
/*  190 */     offset += len;
/*      */     
/*      */ 
/*  193 */     resp_dbVersionCheck(conn.getDmServerVersion(), len);
/*      */     
/*      */ 
/*  196 */     if (conn.getUKeyFlag())
/*      */     {
/*  198 */       conn.setRandom(recvMsg.getString(offset, 16));
/*  199 */       offset += 16;
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*  204 */     if (comm_enc_flag == 1)
/*      */     {
/*  206 */       msgEncryptType = (int)recvMsg.getInt(offset);
/*  207 */       offset += 4;
/*      */     }
/*  209 */     if (gen_keypair_flag == 1)
/*      */     {
/*  211 */       msgCipherType = msgEncryptType;
/*  212 */       if (msgCipherType == -1)
/*      */       {
/*  214 */         pwd_encrypt = true;
/*  215 */         msgCipherType = 132;
/*      */       }
/*      */       
/*  218 */       len = (int)recvMsg.getInt(offset);
/*  219 */       offset += 4;
/*      */       
/*  221 */       byte[] serverPubKey = recvMsg.getBytes(offset, len);
/*  222 */       sessionKey = MsgSecurity.computeSessionKey(conn.getDbAccess().getClientPrivKey(toPrimary), 
/*  223 */         serverPubKey);
/*  224 */       offset += len;
/*      */     }
/*      */     
/*  227 */     conn.getDbAccess().genMsgCiphers(toPrimary, msgCipherType, sessionKey);
/*  228 */     conn.setPwdEncrypt(pwd_encrypt);
/*  229 */     conn.getDbAccess().setMsgEncryptType(msgEncryptType, toPrimary);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_login(DmMsgSend msg, DmdbConnection_bs conn, boolean toPrimary)
/*      */     throws SQLException
/*      */   {
/*  243 */     req_initMsg(msg);
/*      */     
/*      */ 
/*      */ 
/*  247 */     msg.req_login_set_env(2);
/*      */     
/*      */ 
/*  250 */     int iso_level = 0;
/*  251 */     switch (conn.getTransLevel())
/*      */     {
/*      */     case 2: 
/*  254 */       iso_level = 1;
/*  255 */       break;
/*      */     case 8: 
/*  257 */       iso_level = 3;
/*  258 */       break;
/*      */     case 1: 
/*  260 */       iso_level = 0;
/*  261 */       break;
/*      */     case 3: 
/*      */     case 4: 
/*      */     case 5: 
/*      */     case 6: 
/*      */     case 7: 
/*      */     default: 
/*  268 */       iso_level = -1;
/*      */     }
/*  270 */     msg.req_login_set_iso_level(iso_level);
/*      */     
/*      */ 
/*  273 */     msg.req_login_set_language(conn.getLanguage());
/*      */     
/*      */ 
/*  276 */     msg.req_login_set_time_zone(conn.getTz());
/*      */     
/*      */ 
/*  279 */     msg.req_login_set_read_only((byte)conn.getTransAccessMode());
/*      */     
/*      */ 
/*  282 */     msg.req_login_set_session_timeout(conn.getSessionTimeout());
/*      */     
/*      */ 
/*  285 */     if (conn.getMppLocal()) {
/*  286 */       msg.req_login_set_mpp_login_type((byte)1);
/*      */     } else {
/*  288 */       msg.req_login_set_mpp_login_type((byte)0);
/*      */     }
/*      */     
/*  291 */     if (conn.getRwSeparate()) {
/*  292 */       msg.req_login_set_req_standby_flag((byte)1);
/*      */     } else {
/*  294 */       msg.req_login_set_req_standby_flag((byte)0);
/*      */     }
/*      */     
/*  297 */     msg.nmsg_req_login_set_new_lob_flag((byte)1);
/*      */     
/*      */ 
/*  300 */     int offset = 64;
/*      */     
/*      */     try
/*      */     {
/*  304 */       String serverEncoding = conn.getServerEncoding();
/*      */       
/*      */ 
/*  307 */       if (conn.getUKeyFlag())
/*      */       {
/*  309 */         boolean rv = false;
/*  310 */         byte[] buf = conn.getRandom().getBytes(serverEncoding);
/*  311 */         byte[] signdata = new byte['Ѐ'];
/*  312 */         int signdata_len = 1024;
/*      */         
/*  314 */         String uKeyName = conn.getProperties().getProperty("uKeyName");
/*  315 */         DmExternalCrypto INSTANCE = (DmExternalCrypto)Native.loadLibrary(uKeyName, 
/*  316 */           DmExternalCrypto.class);
/*      */         
/*  318 */         IntByReference iref = new IntByReference(1024);
/*  319 */         rv = INSTANCE.cipher_asym_sign(0, null, 0, buf, buf.length, signdata, iref);
/*  320 */         if (!rv)
/*      */         {
/*  322 */           DBError.throwSQLException(6001);
/*      */         }
/*      */         
/*  325 */         signdata_len = iref.getValue();
/*  326 */         offset += msg.setBytesWithLen4(signdata, 0, offset, signdata_len);
/*      */       }
/*      */       
/*      */ 
/*      */ 
/*      */ 
/*  332 */       byte[] userbuf = conn.getLoginName().getBytes(serverEncoding);
/*  333 */       if (userbuf.length > 128) {
/*  334 */         throw new SQLException("User's name is too long");
/*      */       }
/*      */       
/*  337 */       byte[] userpwd = conn.getPassword().getBytes(serverEncoding);
/*  338 */       if (userpwd.length > 128) {
/*  339 */         throw new SQLException(Const.res.getString("error.passwordtoolong"));
/*      */       }
/*  341 */       if (conn.pwd_encrypt())
/*      */       {
/*  343 */         userbuf = conn.getDbAccess().symmetricEncrypto(toPrimary, userbuf, userbuf.length, false);
/*  344 */         userpwd = conn.getDbAccess().symmetricEncrypto(toPrimary, userpwd, userpwd.length, false);
/*      */       }
/*      */       
/*  347 */       offset += msg.setBytesWithLen4(userbuf, 0, offset, userbuf.length);
/*  348 */       offset += msg.setBytesWithLen4(userpwd, 0, offset, userpwd.length);
/*      */       
/*      */ 
/*  351 */       String appName = conn.getAppName();
/*  352 */       if (appName == null) {
/*  353 */         appName = "";
/*      */       }
/*  355 */       byte[] buf = appName.getBytes(serverEncoding);
/*  356 */       offset += msg.setBytesWithLen4(buf, 0, offset, buf.length);
/*      */       
/*      */ 
/*  359 */       buf = conn.getOsName().getBytes(serverEncoding);
/*  360 */       offset += msg.setBytesWithLen4(buf, 0, offset, buf.length);
/*      */       
/*      */ 
/*  363 */       buf = conn.getHostMchName().getBytes(serverEncoding);
/*  364 */       offset += msg.setBytesWithLen4(buf, 0, offset, buf.length);
/*      */ 
/*      */     }
/*      */     catch (UnsupportedEncodingException e)
/*      */     {
/*  369 */       e.printStackTrace();
/*      */     }
/*      */     
/*  372 */     offset = req_login_kerberosInfo(msg, conn, offset);
/*      */     
/*      */ 
/*  375 */     req_setCommonHead(msg, 0, (short)1, offset - 64);
/*      */   }
/*      */   
/*      */   private static final int req_login_kerberosInfo(DmMsgSend msg, DmdbConnection_bs con, int offset)
/*      */   {
/*  380 */     AuthInfo kerberosAuth = con.getKerberosAuth();
/*  381 */     if (kerberosAuth == null) {
/*  382 */       return offset;
/*      */     }
/*  384 */     byte[] buf = kerberosAuth.getOut_buf();
/*  385 */     offset += msg.setBytesWithLen4(buf, 0, offset, buf.length);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  396 */     return offset;
/*      */   }
/*      */   
/*      */   public static final void resp_login(DmMsgRecv recvMsg, DmdbConnection_bs conn) throws SQLException
/*      */   {
/*  401 */     resp_checkErr(recvMsg, conn);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  406 */     conn.setMaxRowSize((short)(int)recvMsg.res_login_get_max_data_len());
/*      */     
/*      */ 
/*  409 */     if (recvMsg.res_login_get_ddl_auto_commit() == 0) {
/*  410 */       conn.setDDL_Auto_commit(false);
/*      */     } else {
/*  412 */       conn.setDDL_Auto_commit(true);
/*      */     }
/*      */     
/*  415 */     switch (recvMsg.res_login_get_iso_level())
/*      */     {
/*      */     case 1: 
/*  418 */       conn.setTransLevel(2);
/*  419 */       break;
/*      */     case 3: 
/*  421 */       conn.setTransLevel(8);
/*  422 */       break;
/*      */     case 2: default: 
/*  424 */       conn.setTransLevel(0);
/*      */     }
/*      */     
/*      */     
/*  428 */     conn.setCaseSensitive(recvMsg.res_login_get_str_case_sensitive() == 1);
/*      */     
/*  430 */     if (recvMsg.res_login_get_back_slash() == 0) {
/*  431 */       conn.setBackslashEscape(false);
/*      */     } else {
/*  433 */       conn.setBackslashEscape(true);
/*      */     }
/*      */     
/*  436 */     conn.setSvrStat(recvMsg.res_login_get_svr_stat());
/*  437 */     conn.setSvrMode(recvMsg.res_login_get_svr_mode());
/*  438 */     conn.setConstParaOpt(recvMsg.res_login_get_const_para_opt());
/*  439 */     conn.setDbTz(recvMsg.res_login_get_db_tz());
/*  440 */     conn.setNewLobFlag(recvMsg.res_login_get_new_lob_flag());
/*      */     
/*      */ 
/*  443 */     String serverEncoding = conn.getServerEncoding();
/*  444 */     int tmpLen = 0;
/*  445 */     int offset = 64;
/*  446 */     offset += recvMsg.getErrlen();
/*      */     
/*      */ 
/*  449 */     tmpLen = (int)recvMsg.getInt(offset);
/*  450 */     offset += 4;
/*      */     
/*  452 */     String instance = recvMsg.getString(offset, tmpLen, serverEncoding);
/*  453 */     conn.setInstanceName(instance);
/*  454 */     offset += tmpLen;
/*      */     
/*      */ 
/*  457 */     tmpLen = (int)recvMsg.getInt(offset);
/*  458 */     offset += 4;
/*      */     
/*  460 */     String currentSch = recvMsg.getString(offset, tmpLen, serverEncoding);
/*  461 */     conn.setSchema(currentSch);
/*  462 */     offset += tmpLen;
/*      */     
/*      */ 
/*  465 */     tmpLen = (int)recvMsg.getInt(offset);
/*  466 */     offset += 4;
/*      */     
/*  468 */     String lastLoginIP = recvMsg.getString(offset, tmpLen);
/*  469 */     offset += tmpLen;
/*  470 */     conn.setLastLoginIP(lastLoginIP);
/*      */     
/*      */ 
/*  473 */     tmpLen = (int)recvMsg.getInt(offset);
/*  474 */     offset += 4;
/*      */     
/*  476 */     String lastLoginTime = recvMsg.getString(offset, tmpLen, serverEncoding);
/*  477 */     offset += tmpLen;
/*  478 */     conn.setLastLoginTime(lastLoginTime);
/*      */     
/*      */ 
/*  481 */     conn.setFailedAttempt((int)recvMsg.getInt(offset));
/*  482 */     offset += 4;
/*      */     
/*      */ 
/*  485 */     conn.setLoginWarningID((int)recvMsg.getInt(offset));
/*  486 */     offset += 4;
/*      */     
/*      */ 
/*  489 */     conn.setGraceTimeRemainder((int)recvMsg.getInt(offset));
/*  490 */     offset += 4;
/*      */     
/*      */ 
/*  493 */     int guidLen = (int)recvMsg.getInt(offset);
/*  494 */     offset += 4;
/*      */     
/*  496 */     String guid = recvMsg.getString(offset, guidLen);
/*  497 */     offset += guidLen;
/*      */     
/*  499 */     conn.setGUID(guid);
/*      */     
/*      */ 
/*  502 */     tmpLen = (int)recvMsg.getInt(offset);
/*  503 */     offset += 4;
/*      */     
/*  505 */     String dbName = recvMsg.getString(offset, tmpLen);
/*  506 */     offset += tmpLen;
/*      */     
/*  508 */     conn.setCurrentDBName(dbName);
/*      */     
/*      */ 
/*  511 */     if (recvMsg.res_login_get_resp_standby() == 0) {
/*  512 */       return;
/*      */     }
/*  514 */     tmpLen = (int)recvMsg.getInt(offset);
/*  515 */     if (tmpLen > 0)
/*      */     {
/*  517 */       offset += 4;
/*      */       
/*  519 */       String sIP = recvMsg.getString(offset, tmpLen);
/*  520 */       offset += tmpLen;
/*      */       
/*      */ 
/*  523 */       int sPort = (int)recvMsg.getInt(offset);
/*  524 */       offset += 4;
/*      */       
/*  526 */       conn.setStandbyInfo(sIP, sPort);
/*      */       
/*      */ 
/*      */ 
/*  530 */       offset += 2;
/*      */     }
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_stmt_alloc(DmMsgSend msg)
/*      */   {
/*  540 */     req_initMsg(msg);
/*      */     
/*  542 */     msg.req_alloc_stmt_set_new_col_desc_flag((byte)1);
/*      */     
/*  544 */     req_setCommonHead(msg, 0, (short)3, 0);
/*      */   }
/*      */   
/*      */   public static final int resp_stmt_alloc(DmMsgRecv recvMsg, DmdbStatement_bs stmt) throws SQLException
/*      */   {
/*  549 */     resp_checkErr(recvMsg, stmt.getConnection_bs());
/*  550 */     stmt.setReadBaseColName(recvMsg.res_alloc_stmt_get_new_col_desc_flag() == 1);
/*  551 */     return recvMsg.res_get_stmtid();
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_stmt_free(DmMsgSend msg, int handle)
/*      */   {
/*  559 */     req_initMsg(msg);
/*      */     
/*  561 */     req_setCommonHead(msg, handle, (short)4, 0);
/*      */   }
/*      */   
/*      */   public static final void resp_stmt_free(DmMsgRecv recvMsg, DmdbConnection_bs conn) throws SQLException
/*      */   {
/*  566 */     resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_prepare(DmMsgSend msg, DmdbStatement_bs stmt, String sql, boolean direct, int checkFlag)
/*      */     throws SQLException
/*      */   {
/*  577 */     req_initMsg(msg);
/*      */     
/*      */ 
/*  580 */     DmdbConnection_bs conn = (DmdbConnection_bs)stmt.getConnection();
/*  581 */     if (conn.getAutoCommit()) {
/*  582 */       msg.req_prepare_set_auto_cmt((byte)1);
/*      */     } else {
/*  584 */       msg.req_prepare_set_auto_cmt((byte)0);
/*      */     }
/*  586 */     if (direct) {
/*  587 */       msg.req_prepare_set_exec_direct((byte)1);
/*      */     } else {
/*  589 */       msg.req_prepare_set_exec_direct((byte)0);
/*      */     }
/*  591 */     msg.req_prepare_set_check_type((byte)1);
/*  592 */     msg.req_prepare_set_sql_Type((short)checkFlag);
/*      */     
/*  594 */     if (stmt.getMaxRowsInner() == 0) {
/*  595 */       msg.req_prepare_set_fetch_max(Long.MAX_VALUE);
/*      */     } else {
/*  597 */       msg.req_prepare_set_fetch_max(stmt.getMaxRowsInner());
/*      */     }
/*  599 */     if (stmt.getResultSetType() == 1003) {
/*  600 */       msg.req_prepare_set_cur_forward_only((byte)1);
/*      */     } else {
/*  602 */       msg.req_prepare_set_cur_forward_only((byte)0);
/*      */     }
/*      */     
/*  605 */     if (stmt.getConnection_bs().isBdtaRS())
/*      */     {
/*  607 */       msg.req_prepare_rs_bdta_flag((byte)2);
/*      */     }
/*      */     else
/*      */     {
/*  611 */       msg.req_prepare_rs_bdta_flag((byte)0);
/*      */     }
/*      */     
/*  614 */     msg.req_prepare_ret_id_flag((byte)(stmt.autoGeneratedKeys() ? 1 : 0));
/*      */     
/*      */ 
/*  617 */     int len = msg.setStringWithNTS(sql, conn.getServerEncoding(), 64);
/*      */     
/*  619 */     req_setCommonHead(msg, stmt.getHandle(), (short)5, len);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final DmdbInfo resp_prepare(DmMsgRecv recvMsg, String serverEncoding, DmdbStatement_bs stmt, boolean direct)
/*      */     throws SQLException
/*      */   {
/*  634 */     int sqlcode = resp_checkErr(recvMsg, (DmdbConnection_bs)stmt.getConnection());
/*      */     
/*  636 */     DmdbInfo des = stmt.getDmdbInfoNRS();
/*  637 */     des.setSQLCode(0);
/*  638 */     if (sqlcode > 0) {
/*  639 */       des.setSQLCode(sqlcode);
/*      */     }
/*      */     
/*  642 */     int cursorHandle = recvMsg.res_get_stmtid();
/*      */     
/*  644 */     if (direct) {
/*  645 */       return resp_prepare_direct(recvMsg, stmt, sqlcode, cursorHandle);
/*      */     }
/*      */     
/*  648 */     return resp_prepare_indirect(recvMsg, stmt, cursorHandle);
/*      */   }
/*      */   
/*      */   private static DmdbInfo resp_prepare_direct(DmMsgRecv recvMsg, DmdbStatement_bs stmt, int sqlcode, int refHandle)
/*      */     throws SQLException
/*      */   {
/*  654 */     return resp_execute_without_checkErr(recvMsg, stmt, sqlcode, refHandle);
/*      */   }
/*      */   
/*      */   private static DmdbInfo resp_prepare_indirect(DmMsgRecv recvMsg, DmdbStatement_bs stmt, int refHandle)
/*      */     throws SQLException
/*      */   {
/*  660 */     int paraNum = recvMsg.res_prepare_get_param_num();
/*  661 */     int colNum = recvMsg.res_prepare_get_col_num();
/*      */     
/*  663 */     DmdbConnection_bs conn = (DmdbConnection_bs)stmt.getConnection();
/*      */     
/*  665 */     int retCmd = recvMsg.res_prepare_get_ret_type();
/*      */     
/*  667 */     DmdbInfo des = stmt.getDmdbInfoNRS();
/*      */     
/*  669 */     des.setRetStmtType(retCmd);
/*      */     
/*  671 */     conn.setTransStatus(recvMsg.res_prepare_get_trans_status());
/*      */     
/*  673 */     if ((retCmd == 201) || (retCmd == 200)) {
/*  674 */       stmt.cursorUpdateRow = conn.getCurpos(refHandle);
/*      */     }
/*  676 */     int offset = 64;
/*      */     
/*  678 */     offset = resp_getParaDesc(recvMsg, offset, paraNum, des, stmt);
/*      */     
/*      */ 
/*  681 */     offset = resp_getColDesc(recvMsg, offset, colNum, des, stmt);
/*      */     
/*  683 */     return des;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_execute(boolean preExeced, DmMsgSend msg, DmdbStatement_bs stmt, long curPos, int irow)
/*      */     throws SQLException
/*      */   {
/*  694 */     int retLen = 0;
/*  695 */     DmdbPreparedStatement_bs pstmt = null;
/*      */     
/*  697 */     req_initMsg(msg);
/*      */     
/*  699 */     int paramCnt = 0;
/*  700 */     DmBinder[] binders = null;
/*  701 */     if ((stmt instanceof DmdbPreparedStatement_bs))
/*      */     {
/*  703 */       pstmt = (DmdbPreparedStatement_bs)stmt;
/*  704 */       binders = pstmt.getParamBoundDesc();
/*  705 */       paramCnt = binders.length;
/*      */     }
/*      */     
/*  708 */     req_execute_cmd_head(msg, stmt.getConnection().getAutoCommit(), stmt.getResultSetType(), 
/*  709 */       stmt.getMaxRowsInner(), curPos, 1, paramCnt, stmt.autoGeneratedKeys(), stmt
/*  710 */       .getConnection_bs().getContinueBatchOnError());
/*      */     
/*  712 */     if (paramCnt > 0)
/*      */     {
/*  714 */       retLen += req_execute_cmd_body_paratype(msg, binders, false);
/*  715 */       retLen += req_execute_cmd_body_paraData(false, preExeced, msg, pstmt, irow, binders);
/*      */     }
/*      */     
/*  718 */     if (stmt.getConnection_bs().getIsExecute2())
/*      */     {
/*  720 */       req_setCommonHead(msg, stmt.getHandle(), (short)13, retLen);
/*      */     }
/*      */     else {
/*  723 */       req_setCommonHead(msg, stmt.getHandle(), (short)6, retLen);
/*      */     }
/*      */   }
/*      */   
/*      */   public static final void req_execute_sendCurInfo(boolean preExeced, DmMsgSend msg, DmdbStatement_bs stmt, long curPos) throws SQLException
/*      */   {
/*  729 */     req_initMsg(msg);
/*      */     
/*  731 */     req_execute_cmd_head(msg, stmt.getConnection().getAutoCommit(), stmt.getResultSetType(), 
/*  732 */       stmt.getMaxRowsInner(), curPos, 1, 0, stmt.autoGeneratedKeys(), stmt.getConnection_bs()
/*  733 */       .getContinueBatchOnError());
/*  734 */     if (stmt.getConnection_bs().getIsExecute2())
/*      */     {
/*  736 */       req_setCommonHead(msg, stmt.getHandle(), (short)13, 0);
/*      */     }
/*      */     else
/*      */     {
/*  740 */       req_setCommonHead(msg, stmt.getHandle(), (short)6, 0);
/*      */     }
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final int req_execute_for_batch(boolean preExeced, int curRow, DmMsgSend msg, DmdbPreparedStatement_bs stmt)
/*      */     throws SQLException
/*      */   {
/*  756 */     int startRow = curRow;
/*  757 */     int batchSize = stmt.getBatchSize();
/*  758 */     int nextRow = batchSize;
/*  759 */     int typeLen = 0;
/*  760 */     int totalLen = 0;
/*  761 */     DmBinder[] binder = stmt.getParamBoundDesc();
/*  762 */     int paramCount = binder.length;
/*      */     
/*  764 */     req_initMsg(msg);
/*      */     
/*  766 */     for (int i = startRow; i < batchSize; i++)
/*      */     {
/*  768 */       if (i == startRow)
/*      */       {
/*  770 */         typeLen = req_execute_cmd_body_paratype(msg, binder, true);
/*  771 */         totalLen += typeLen;
/*      */       }
/*      */       
/*  774 */       int dateLen = req_execute_cmd_body_paraData(true, preExeced, msg, stmt, i, binder);
/*      */       
/*      */ 
/*  777 */       if (dateLen == 0)
/*      */       {
/*  779 */         nextRow = i;
/*  780 */         break;
/*      */       }
/*      */       
/*      */ 
/*  784 */       totalLen += dateLen;
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*  789 */     if (startRow == nextRow) {
/*  790 */       return nextRow;
/*      */     }
/*  792 */     req_execute_cmd_head(msg, stmt.getConnection().getAutoCommit(), stmt.getResultSetType(), 
/*  793 */       stmt.getMaxRowsInner(), stmt.cursorUpdateRow, nextRow - startRow, paramCount, 
/*  794 */       stmt.autoGeneratedKeys(), stmt.getConnection_bs().getContinueBatchOnError());
/*      */     
/*  796 */     if (stmt.getConnection_bs().getIsExecute2())
/*      */     {
/*  798 */       req_setCommonHead(msg, stmt.getHandle(), (short)13, totalLen);
/*      */     }
/*      */     else
/*      */     {
/*  802 */       req_setCommonHead(msg, stmt.getHandle(), (short)6, totalLen);
/*      */     }
/*      */     
/*  805 */     return nextRow;
/*      */   }
/*      */   
/*      */   public static final int[] resp_execute_for_batch(DmMsgRecv recv, DmdbStatement_bs stmt)
/*      */     throws SQLException
/*      */   {
/*  811 */     DmdbConnection_bs conn = (DmdbConnection_bs)stmt.getConnection();
/*  812 */     int sqlcode = resp_checkErr(recv, conn);
/*      */     
/*  814 */     DmdbInfo des = stmt.getDmdbInfoNRS();
/*  815 */     des = resp_execute_cmd_head(recv, des, stmt);
/*      */     
/*  817 */     int[] rowCounts = null;
/*  818 */     int offset = 64;
/*      */     
/*  820 */     long msgLen = recv.res_get_len();
/*  821 */     if (offset >= msgLen + 64L) {
/*  822 */       return rowCounts;
/*      */     }
/*  824 */     if (des.hasBatchRowCnt())
/*      */     {
/*  826 */       int counts = (int)recv.getInt(offset);
/*  827 */       offset += 4;
/*      */       
/*  829 */       rowCounts = new int[counts];
/*  830 */       for (int i = 0; i < counts; i++)
/*      */       {
/*  832 */         rowCounts[i] = ((int)recv.getLong(offset));
/*  833 */         offset += 8;
/*      */       }
/*      */     }
/*      */     
/*  837 */     if (des.hasRetIds())
/*      */     {
/*  839 */       int rows = (int)recv.getInt(offset);
/*  840 */       offset += 4;
/*      */       
/*  842 */       long[] retIds = new long[rows];
/*  843 */       for (int i = 0; i < rows; i++)
/*      */       {
/*  845 */         retIds[i] = recv.getLong(offset);
/*  846 */         offset += 8;
/*      */       }
/*      */       
/*  849 */       stmt.setRetIds(retIds);
/*      */     }
/*      */     
/*  852 */     if (sqlcode == 121)
/*      */     {
/*  854 */       if ((stmt instanceof DmdbPreparedStatement_bs))
/*      */       {
/*  856 */         ((DmdbPreparedStatement_bs)stmt).setBpWithErr(true);
/*      */       }
/*  858 */       offset = resp_exec_build_idu_warn_diag(recv, conn, offset, rowCounts);
/*      */     }
/*      */     
/*  861 */     return rowCounts;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */   private static int resp_exec_build_idu_warn_diag(DmMsgRecv recv, DmdbConnection_bs conn, int offset, int[] rowCounts)
/*      */   {
/*  868 */     offset += 4;
/*      */     
/*  870 */     int warn_cnt = (int)recv.getInt(offset);
/*  871 */     offset += 4;
/*      */     
/*  873 */     for (int i = 0; i < warn_cnt; i++)
/*      */     {
/*  875 */       int rowi = (int)recv.getInt(offset);
/*  876 */       offset += 4;
/*      */       
/*  878 */       rowCounts[rowi] = -3;
/*      */       
/*  880 */       int code = (int)recv.getInt(offset);
/*  881 */       offset += 4;
/*      */       
/*  883 */       int err_len = recv.getShort(offset);
/*  884 */       offset += 2;
/*      */       
/*  886 */       String errStr = "";
/*  887 */       if (err_len > 0)
/*      */       {
/*  889 */         errStr = Convertion.getString(recv.getBuffer(), offset, err_len, conn.getServerEncoding());
/*  890 */         offset += err_len;
/*      */       }
/*      */       
/*  893 */       SQLWarning warning = new SQLWarning("row[" + rowi + "]:" + code + ", " + errStr);
/*  894 */       conn.addWarnings(warning);
/*      */     }
/*      */     
/*      */ 
/*  898 */     return offset;
/*      */   }
/*      */   
/*      */ 
/*      */   private static void req_execute_cmd_head(DmMsgSend msg, boolean autoCommit, int rsType, int stmtMaxRows, long curPos, int rowCnt, int paramCnt, boolean ret_id_flag, boolean ign_bp_err)
/*      */     throws SQLException
/*      */   {
/*  905 */     if (autoCommit) {
/*  906 */       msg.req_execute_set_auto_cmt((byte)1);
/*      */     } else {
/*  908 */       msg.req_execute_set_auto_cmt((byte)0);
/*      */     }
/*  910 */     if (rsType == 1003) {
/*  911 */       msg.req_execute_set_cur_forward_only((byte)1);
/*      */     } else {
/*  913 */       msg.req_execute_set_cur_forward_only((byte)0);
/*      */     }
/*  915 */     if (stmtMaxRows == 0) {
/*  916 */       msg.req_execute_set_fetch_max(Long.MAX_VALUE);
/*      */     } else {
/*  918 */       msg.req_execute_set_fetch_max(stmtMaxRows);
/*      */     }
/*  920 */     msg.req_execute_set_row_num(rowCnt);
/*  921 */     msg.req_execute_set_param_num((short)paramCnt);
/*  922 */     msg.req_execute_set_cur_pos(curPos);
/*      */     
/*  924 */     if (ret_id_flag) {
/*  925 */       msg.req_execute_ret_id_flag((byte)1);
/*      */     } else {
/*  927 */       msg.req_execute_ret_id_flag((byte)0);
/*      */     }
/*  929 */     if (ign_bp_err) {
/*  930 */       msg.req_execute_ign_bp_err((byte)1);
/*      */     } else {
/*  932 */       msg.req_execute_ign_bp_err((byte)0);
/*      */     }
/*      */   }
/*      */   
/*      */   private static int req_execute_cmd_body_paratype(DmMsgSend msg, DmBinder[] binders, boolean forBatch) throws SQLException
/*      */   {
/*  938 */     int paramTotal = binders == null ? 0 : binders.length;
/*  939 */     int retLen = 0;
/*      */     
/*  941 */     for (int i = 0; i < paramTotal; i++)
/*      */     {
/*  943 */       retLen += binders[i].bindDesc(msg, i, forBatch);
/*      */     }
/*      */     
/*  946 */     return retLen;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private static int req_execute_cmd_body_paraData(boolean forBatch, boolean preExeced, DmMsgSend msgSend, DmdbPreparedStatement_bs stmt, int irow, DmBinder[] binders)
/*      */     throws SQLException
/*      */   {
/*  963 */     int paramTotal = binders == null ? 0 : binders.length;
/*  964 */     int retLen = 0;
/*      */     
/*      */ 
/*  967 */     byte[][] isNull = stmt.getNullIndicator();
/*      */     
/*  969 */     for (int i = 0; i < paramTotal; i++)
/*      */     {
/*  971 */       if (((binders[i] instanceof DmOutParamBinder)) && (
/*  972 */         (binders[i].checkIOType((byte)1)) || 
/*  973 */         (binders[i].checkIOType((byte)2)))) { int outLen;
/*      */         int outLen;
/*  975 */         if (isNull[irow][i] == 1) {
/*  976 */           outLen = DmNullBinder.bindData(msgSend);
/*      */         } else {
/*  978 */           outLen = binders[i].bindData(msgSend, irow, i, forBatch);
/*      */         }
/*  980 */         if (outLen != 0) {
/*  981 */           retLen += outLen;
/*      */         }
/*  983 */         if ((outLen != 0) || (binders[i].checkIOType((byte)1))) {}
/*      */       } else {
/*      */         int dateLen;
/*      */         int dateLen;
/*  987 */         if (isNull[irow][i] == 1) {
/*  988 */           dateLen = DmNullBinder.bindData(msgSend);
/*      */         } else {
/*  990 */           dateLen = binders[i].bindData(msgSend, irow, i, forBatch);
/*      */         }
/*  992 */         if (dateLen == -1)
/*      */         {
/*      */ 
/*  995 */           if (forBatch)
/*      */           {
/*  997 */             msgSend.cutBufferLen(retLen);
/*  998 */             return 0;
/*      */           }
/*      */           
/* 1001 */           msgSend.setParamDataLength(0);
/* 1002 */           retLen += 2;
/*      */           
/* 1004 */           if (!preExeced) {
/* 1005 */             DmdbCSI.preExec(stmt, binders, forBatch);
/*      */           }
/* 1007 */           preExeced = true;
/*      */           
/* 1009 */           DmdbCSI.putBlobData(stmt, irow, i, binders[i]);
/*      */         }
/*      */         else {
/* 1012 */           retLen += dateLen;
/*      */         }
/*      */       } }
/* 1015 */     for (int i = 0; i < paramTotal; i++)
/*      */     {
/* 1017 */       if (((binders[i] instanceof DmInputStreamBinder)) || ((binders[i] instanceof DmReaderBinder)))
/*      */       {
/* 1019 */         binders[i].clearRetValue();
/*      */       }
/*      */     }
/* 1022 */     return retLen;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final DmdbInfo resp_execute(DmMsgRecv recv, DmdbStatement_bs stmt)
/*      */     throws SQLException
/*      */   {
/* 1037 */     DmdbConnection_bs connect = (DmdbConnection_bs)stmt.getConnection();
/* 1038 */     int sqlcode = resp_checkErr(recv, connect);
/*      */     
/* 1040 */     return resp_execute_without_checkErr(recv, stmt, sqlcode, 0);
/*      */   }
/*      */   
/*      */   private static DmdbInfo resp_execute_without_checkErr(DmMsgRecv recv, DmdbStatement_bs stmt, int sqlcode, int refHandle)
/*      */     throws SQLException
/*      */   {
/* 1046 */     DmdbInfo des = stmt.getDmdbInfoNRS();
/* 1047 */     des = resp_execute_cmd_head(recv, des, stmt);
/*      */     
/* 1049 */     DmdbConnection_bs connect = (DmdbConnection_bs)stmt.getConnection();
/* 1050 */     DmdbPreparedStatement_bs pstmt = null;
/* 1051 */     int outParamCount = des.getParmCount();
/*      */     
/* 1053 */     int offset = 64;
/* 1054 */     int printMsgLen = 0;
/*      */     
/* 1056 */     if (sqlcode == 111) {
/* 1057 */       des.setRowCount(-1L);
/*      */     }
/* 1059 */     switch (des.getRetStmtType())
/*      */     {
/*      */     case 165: 
/* 1062 */       des.setSavepointFlag(true);
/* 1063 */       short tz = (short)recv.getShort(offset);
/* 1064 */       offset += 2;
/* 1065 */       connect.setTz(tz);
/* 1066 */       break;
/*      */     
/*      */     case 200: 
/*      */     case 201: 
/* 1070 */       if ((stmt instanceof DmdbPreparedStatement_bs))
/*      */       {
/* 1072 */         pstmt = (DmdbPreparedStatement_bs)stmt;
/* 1073 */         if (outParamCount > 0) {
/* 1074 */           offset = resp_execute_cmd_head_param(recv, pstmt.getParamBoundDesc(), outParamCount, 
/* 1075 */             offset);
/*      */         }
/*      */       }
/* 1078 */       if (107 == sqlcode)
/*      */       {
/* 1080 */         stmt.cursorUpdateRow = connect.getCurpos(refHandle);
/* 1081 */         recv = DmdbCSI.sendCurPosInfo(stmt, stmt.cursorUpdateRow);
/*      */       }
/* 1083 */       break;
/*      */     
/*      */     case 166: 
/* 1086 */       des.setSavepointFlag(true);
/* 1087 */       switch (recv.getShort(offset))
/*      */       {
/*      */       case 1: 
/* 1090 */         connect.setTransLevel(2);
/* 1091 */         break;
/*      */       case 3: 
/* 1093 */         connect.setTransLevel(8);
/* 1094 */         break;
/*      */       case 2: default: 
/* 1096 */         connect.setTransLevel(0);
/*      */       }
/* 1098 */       offset += 2;
/* 1099 */       connect.setTransAccessMode(recv.getByte(offset));
/* 1100 */       offset++;
/* 1101 */       break;
/*      */     
/*      */     case 153: 
/* 1104 */       des.setSavepointFlag(true);
/* 1105 */       int schlen = (int)recv.getInt(offset);
/* 1106 */       offset += 4;
/* 1107 */       String schname = recv.getString(offset, schlen, connect.getServerEncoding());
/* 1108 */       connect.setSchema(schname);
/* 1109 */       offset += schlen;
/* 1110 */       break;
/*      */     
/*      */     case 149: 
/* 1113 */       int exlen = (int)recv.getInt(offset);
/* 1114 */       offset += 4;
/* 1115 */       String exStr = recv.getString(offset, exlen, connect.getServerEncoding());
/* 1116 */       des.setExplain(exStr);
/* 1117 */       offset += exlen;
/* 1118 */       break;
/*      */     
/*      */     case 160: 
/* 1121 */       printMsgLen = (int)des.getPrintLen();
/* 1122 */       if (printMsgLen > 0)
/*      */       {
/* 1124 */         String val = recv.getString(offset, printMsgLen, connect.getServerEncoding());
/* 1125 */         des.setPrintMsg(val);
/*      */         
/* 1127 */         offset += printMsgLen;
/*      */       }
/*      */       
/* 1130 */       if (111 != sqlcode)
/*      */       {
/* 1132 */         offset = resp_getColDesc(recv, offset, des.getColCount(), des, stmt);
/*      */         
/* 1134 */         int rowidCol = -1;
/* 1135 */         if (des.isBdtaRs())
/*      */         {
/* 1137 */           rowidCol = recv.res_execute_rs_rowid_colindex();
/*      */         }
/* 1139 */         des.setHasResultSet(true);
/* 1140 */         resp_getResultSetData(stmt, recv, des.getRowCount(), des.getColumnsInfo(), offset, 
/* 1141 */           des.getRsCacheOffset(), rowidCol, des.isBdtaRs());
/*      */       }
/* 1143 */       break;
/*      */     
/*      */     case 162: 
/* 1146 */       printMsgLen = (int)des.getPrintLen();
/* 1147 */       if (printMsgLen > 0)
/*      */       {
/* 1149 */         String val = recv.getString(offset, printMsgLen, connect.getServerEncoding());
/* 1150 */         des.setPrintMsg(val);
/*      */         
/* 1152 */         offset += printMsgLen;
/*      */       }
/*      */       
/* 1155 */       if ((stmt instanceof DmdbPreparedStatement_bs))
/*      */       {
/* 1157 */         pstmt = (DmdbPreparedStatement_bs)stmt;
/* 1158 */         if (outParamCount > 0) {
/* 1159 */           offset = resp_execute_cmd_head_param(recv, pstmt.getParamBoundDesc(), outParamCount, 
/* 1160 */             offset);
/*      */         }
/*      */       }
/* 1163 */       if (111 != sqlcode)
/*      */       {
/* 1165 */         offset = resp_getColDesc(recv, offset, des.getColCount(), des, stmt);
/*      */         
/* 1167 */         int rowidCol = -1;
/* 1168 */         if (des.isBdtaRs())
/*      */         {
/* 1170 */           rowidCol = recv.res_execute_rs_rowid_colindex();
/*      */         }
/* 1172 */         resp_getResultSetData(stmt, recv, des.getRowCount(), des.getColumnsInfo(), offset, 
/* 1173 */           des.getRsCacheOffset(), rowidCol, des.isBdtaRs());
/*      */       }
/* 1175 */       break;
/*      */     
/*      */     case 161: 
/* 1178 */       pstmt = (DmdbPreparedStatement_bs)stmt;
/* 1179 */       if (outParamCount > 0)
/* 1180 */         offset = resp_execute_cmd_head_param(recv, pstmt.getParamBoundDesc(), outParamCount, 
/* 1181 */           offset);
/* 1182 */       break;
/*      */     
/*      */     case 159: 
/* 1185 */       if ((stmt instanceof DmdbPreparedStatement_bs))
/*      */       {
/* 1187 */         pstmt = (DmdbPreparedStatement_bs)stmt;
/* 1188 */         if (outParamCount > 0)
/* 1189 */           offset = resp_execute_cmd_head_param(recv, pstmt.getParamBoundDesc(), outParamCount, 
/* 1190 */             offset);
/*      */       }
/* 1192 */       des.setHasResultSet(false);
/* 1193 */       if (sqlcode == 111)
/* 1194 */         des.setRowCount(-1L);
/* 1195 */       break;
/*      */     
/*      */     case 158: 
/* 1198 */       if ((stmt instanceof DmdbPreparedStatement_bs))
/*      */       {
/* 1200 */         pstmt = (DmdbPreparedStatement_bs)stmt;
/* 1201 */         if (outParamCount > 0)
/* 1202 */           offset = resp_execute_cmd_head_param(recv, pstmt.getParamBoundDesc(), outParamCount, 
/* 1203 */             offset);
/*      */       }
/* 1205 */       des.setHasResultSet(false);
/* 1206 */       if (sqlcode == 111)
/* 1207 */         des.setRowCount(-1L);
/* 1208 */       break;
/*      */     
/*      */ 
/*      */     case 157: 
/* 1212 */       if ((des.hasRetIds()) && (stmt.autoGeneratedKeys()))
/*      */       {
/* 1214 */         long[] retIds = new long[1];
/* 1215 */         retIds[0] = des.getRowId();
/* 1216 */         stmt.setRetIds(retIds);
/*      */       }
/* 1218 */       if (((stmt instanceof DmdbPreparedStatement_bs)) || ((stmt instanceof DmdbCallableStatement_bs)))
/*      */       {
/* 1220 */         pstmt = (DmdbPreparedStatement_bs)stmt;
/* 1221 */         if (outParamCount > 0)
/* 1222 */           offset = resp_execute_cmd_head_param(recv, pstmt.getParamBoundDesc(), outParamCount, 
/* 1223 */             offset);
/*      */       }
/* 1225 */       break;
/*      */     
/*      */     case 147: 
/*      */     case 148: 
/*      */     case 151: 
/* 1230 */       des.setSavepointFlag(true);
/* 1231 */       break;
/*      */     
/*      */ 
/*      */     default: 
/* 1235 */       des.setHasResultSet(false);
/* 1236 */       if (sqlcode == 111) {
/* 1237 */         des.setRowCount(-1L);
/*      */       }
/*      */       break;
/*      */     }
/* 1241 */     return des;
/*      */   }
/*      */   
/*      */   private static DmdbInfo resp_execute_cmd_head(DmMsgRecv recv, DmdbInfo des, DmdbStatement_bs stmt)
/*      */     throws SQLException
/*      */   {
/* 1247 */     short ret_type = recv.res_execute_get_ret_type();
/* 1248 */     if (ret_type != 0)
/*      */     {
/* 1250 */       des.setRetStmtType(recv.res_execute_get_ret_type());
/*      */     }
/*      */     
/* 1253 */     des.setColCount(recv.res_execute_get_col_num());
/*      */     
/* 1255 */     des.setRowCount(recv.res_execute_get_row_num());
/*      */     
/* 1257 */     des.setParmCount(recv.res_execute_get_param_num());
/*      */     
/* 1259 */     if (recv.res_execute_get_rs_updatable() == 0) {
/* 1260 */       des.setUpdatable(false);
/*      */     } else {
/* 1262 */       des.setUpdatable(true);
/*      */     }
/* 1264 */     des.setFetchedRows(recv.res_execute_get_fetched_rows());
/*      */     
/* 1266 */     des.setPrintLen(recv.getOffsetOfPrintMsg());
/*      */     
/* 1268 */     if ((des.getRetStmtType() == 160) || (des.getRetStmtType() == 162))
/*      */     {
/* 1270 */       des.setRowId(0L);
/* 1271 */       des.setBdtaRs(recv.res_execute_rs_bdta_flag() == 2);
/*      */     }
/*      */     else
/*      */     {
/* 1275 */       des.setRowId(recv.res_execute_get_rowid());
/*      */     }
/*      */     
/* 1278 */     stmt.setExecuteId(recv.res_execute_get_exid());
/*      */     
/* 1280 */     des.setRsCacheOffset(recv.res_rsCache_offset());
/*      */     
/* 1282 */     des.setBatchRowCntFlag(recv.res_execute_rowcnt_flag());
/*      */     
/* 1284 */     des.setRetIdsFlag(recv.res_execute_retid_flag());
/*      */     
/* 1286 */     DmdbConnection_bs conn = stmt.getConnection_bs();
/* 1287 */     conn.setTransStatus(recv.res_execute_trans_status());
/* 1288 */     return des;
/*      */   }
/*      */   
/*      */   private static int resp_execute_cmd_head_param(DmMsgRecv recv, DmBinder[] binders, int outParaNum, int offset)
/*      */     throws SQLException
/*      */   {
/* 1294 */     int[] foot = new int[outParaNum];
/*      */     
/* 1296 */     int allParamCount = binders.length;
/* 1297 */     int j = 0;
/* 1298 */     for (int i = 0; i < allParamCount; i++)
/*      */     {
/* 1300 */       if (!binders[i].checkIOType((byte)0))
/*      */       {
/* 1302 */         foot[j] = i;
/* 1303 */         j++;
/*      */       }
/*      */     }
/*      */     
/*      */ 
/*      */ 
/* 1309 */     byte[] value = null;
/* 1310 */     for (int i = 0; i < outParaNum; i++)
/*      */     {
/* 1312 */       boolean isOutNull = false;
/* 1313 */       long outParamValueLen = recv.getShort(offset);
/* 1314 */       offset += 2;
/*      */       
/* 1316 */       if (outParamValueLen == 65534L)
/*      */       {
/* 1318 */         outParamValueLen = 0L;
/* 1319 */         isOutNull = true;
/*      */       }
/*      */       
/* 1322 */       if (outParamValueLen == 65535L)
/*      */       {
/* 1324 */         outParamValueLen = recv.getInt(offset);
/* 1325 */         offset += 4;
/*      */       }
/*      */       
/* 1328 */       if (isOutNull)
/*      */       {
/* 1330 */         binders[foot[i]].setOutValue(null);
/* 1331 */         binders[foot[i]].setOutNullFlag(true);
/*      */       }
/*      */       else
/*      */       {
/* 1335 */         if (outParamValueLen > 2147483647L) {
/* 1336 */           throw new SQLException(Const.res.getString("error.valLenTLong"));
/*      */         }
/* 1338 */         value = recv.getBytes(offset, (int)outParamValueLen);
/* 1339 */         binders[foot[i]].setOutValue(value);
/* 1340 */         binders[foot[i]].setOutNullFlag(false);
/*      */       }
/*      */       
/* 1343 */       offset = (int)(offset + outParamValueLen);
/*      */     }
/*      */     
/* 1346 */     return offset;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_exec_direct(DmMsgSend msg, DmdbStatement_bs stmt, DmdbExecOpt execOpt)
/*      */     throws SQLException
/*      */   {
/* 1360 */     req_initMsg(msg);
/*      */     
/* 1362 */     req_execute_cmd_head(msg, stmt.getConnection().getAutoCommit(), stmt.getResultSetType(), 
/* 1363 */       stmt.getMaxRowsInner(), stmt.cursorUpdateRow, 1, execOpt.getParamCount(), 
/* 1364 */       stmt.autoGeneratedKeys(), stmt.getConnection_bs().getContinueBatchOnError());
/*      */     
/* 1366 */     int offset = 64;
/*      */     
/* 1368 */     DmdbConnection_bs conn = (DmdbConnection_bs)stmt.getConnection();
/*      */     
/* 1370 */     String sql = execOpt.getSqlStr();
/* 1371 */     int len = msg.setStringWithNTS(sql, conn.getServerEncoding(), offset);
/* 1372 */     offset += len;
/*      */     
/* 1374 */     msg.setBytes(execOpt.getTypes(), 0, offset, execOpt.getTypesLen());
/* 1375 */     offset += execOpt.getTypesLen();
/*      */     
/* 1377 */     msg.setBytes(execOpt.getValues(), 0, offset, execOpt.getValuesLen());
/* 1378 */     offset += execOpt.getValuesLen();
/*      */     
/*      */ 
/* 1381 */     req_setCommonHead(msg, stmt.getHandle(), (short)91, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */   public static final void req_exec_direct(DmMsgSend msg, DmdbPreparedStatement_bs stmt, String sql)
/*      */     throws SQLException
/*      */   {
/* 1388 */     req_initMsg(msg);
/*      */     
/* 1390 */     DmBinder[] binders = stmt.getParamBoundDesc();
/*      */     
/* 1392 */     int paramCount = binders.length;
/*      */     
/* 1394 */     req_execute_cmd_head(msg, stmt.getConnection().getAutoCommit(), stmt.getResultSetType(), 
/* 1395 */       stmt.getMaxRowsInner(), stmt.cursorUpdateRow, 1, paramCount, stmt.autoGeneratedKeys(), stmt
/* 1396 */       .getConnection_bs().getContinueBatchOnError());
/*      */     
/* 1398 */     int offset = 64;
/*      */     
/* 1400 */     DmdbConnection_bs conn = (DmdbConnection_bs)stmt.getConnection();
/*      */     
/* 1402 */     int len = msg.setStringWithNTS(sql, conn.getServerEncoding(), offset);
/* 1403 */     offset += len;
/*      */     
/* 1405 */     if (paramCount > 0)
/*      */     {
/* 1407 */       offset = req_execute_cmd_body_paratype(msg, binders, false);
/* 1408 */       offset = req_execute_cmd_body_paraData(false, false, msg, stmt, 0, binders);
/*      */     }
/*      */     
/*      */ 
/* 1412 */     req_setCommonHead(msg, stmt.getHandle(), (short)91, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final DmdbInfo resp_exec_direct(DmMsgRecv recv, DmdbStatement_bs stmt)
/*      */     throws SQLException
/*      */   {
/* 1426 */     return resp_execute(recv, stmt);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_pre_exec(int handle, DmMsgSend blobMsg, ParameterDesc[] paramsDesc)
/*      */   {
/* 1437 */     req_initMsg(blobMsg);
/*      */     
/* 1439 */     int paramTotal = paramsDesc.length;
/* 1440 */     ParameterDesc paramDesc = null;
/*      */     
/*      */ 
/* 1443 */     blobMsg.req_preexec_set_param_num((short)paramsDesc.length);
/*      */     
/*      */ 
/* 1446 */     int offset = 64;
/*      */     
/* 1448 */     for (int i = 0; i < paramTotal; i++)
/*      */     {
/* 1450 */       paramDesc = paramsDesc[i];
/*      */       
/* 1452 */       if (paramDesc.getIOType() != 1)
/*      */       {
/*      */ 
/* 1455 */         int type = resp_getDatatype(paramDesc);
/* 1456 */         blobMsg.setByte(paramDesc.getIOType(), offset);
/* 1457 */         offset++;
/*      */         
/* 1459 */         blobMsg.setInt(type, offset);
/* 1460 */         offset += 4;
/*      */         
/* 1462 */         int prec = resp_getDataPrec(paramDesc);
/* 1463 */         blobMsg.setInt(prec, offset);
/* 1464 */         offset += 4;
/*      */         
/* 1466 */         int scale = resp_getDataScale(paramDesc);
/* 1467 */         blobMsg.setInt(scale, offset);
/* 1468 */         offset += 4;
/*      */       }
/*      */     }
/*      */     
/* 1472 */     req_setCommonHead(blobMsg, handle, (short)90, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */   public static final void req_pre_exec(int handle, DmMsgSend blobMsg, DmBinder[] binders, boolean forBatch)
/*      */     throws SQLException
/*      */   {
/* 1479 */     req_initMsg(blobMsg);
/*      */     
/* 1481 */     int paramTotal = binders.length;
/*      */     
/*      */ 
/* 1484 */     blobMsg.req_preexec_set_param_num((short)paramTotal);
/*      */     
/*      */ 
/* 1487 */     int msgLen = 0;
/* 1488 */     for (int i = 0; i < paramTotal; i++) {
/* 1489 */       msgLen += binders[i].bindDesc(blobMsg, i, forBatch);
/*      */     }
/*      */     
/* 1492 */     req_setCommonHead(blobMsg, handle, (short)90, msgLen);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void resp_pre_exec(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 1505 */     resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_fetch(DmMsgSend msg, int handle, DataOfFetch dataFetch)
/*      */   {
/* 1519 */     req_initMsg(msg);
/*      */     
/* 1521 */     msg.req_fetch_set_row_count(dataFetch.getRowCntToGet());
/* 1522 */     msg.req_fetch_set_cur_pos(dataFetch.getCurPos());
/* 1523 */     msg.req_fetch_set_res_id(dataFetch.getResId());
/*      */     
/* 1525 */     req_setCommonHead(msg, handle, (short)7, 0);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final int resp_fetch_checkErr(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 1539 */     return resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */   public static final byte[] resp_fetch_without_checkErr(DmMsgRecv recvMsg, DataOfFetch dataOfFetch, DmdbResultSet_bs resultSet, byte[] buf, boolean isFetchData)
/*      */     throws SQLException
/*      */   {
/* 1545 */     int bufLen = 32640;
/* 1546 */     long msgBufLen = 0L;
/* 1547 */     long totalLen = dataOfFetch.getMsglen_total();
/*      */     
/* 1549 */     int fetchNum = dataOfFetch.getResRowCnt_get();
/* 1550 */     long curPos = dataOfFetch.getCurPos();
/*      */     
/* 1552 */     if (isFetchData)
/*      */     {
/* 1554 */       byte[] buf2 = null;
/*      */       
/* 1556 */       if (buf == null) {
/* 1557 */         buf = new byte[bufLen];
/*      */       }
/* 1559 */       msgBufLen = recvMsg.res_get_len();
/* 1560 */       if (totalLen + msgBufLen > bufLen)
/*      */       {
/* 1562 */         buf2 = new byte[(int)(totalLen + msgBufLen)];
/* 1563 */         System.arraycopy(buf, 0, buf2, 0, buf.length);
/* 1564 */         buf = buf2;
/*      */       }
/*      */       
/* 1567 */       int offset = dataOfFetch.getOffset();
/* 1568 */       System.arraycopy(recvMsg.getBuffer(), 64, buf, offset, (int)msgBufLen);
/*      */       
/* 1570 */       offset = (int)(offset + recvMsg.res_get_len());
/* 1571 */       dataOfFetch.setOffset(offset);
/*      */       
/* 1573 */       if ((recvMsg.res_fetch_get_row_count() != Long.MAX_VALUE) && (resultSet != null)) {
/* 1574 */         resultSet.rowCount = recvMsg.res_fetch_get_row_count();
/*      */       }
/*      */     }
/* 1577 */     totalLen += recvMsg.res_get_len();
/* 1578 */     fetchNum += recvMsg.res_fetch_get_ret_count();
/* 1579 */     curPos += recvMsg.res_fetch_get_ret_count();
/*      */     
/* 1581 */     dataOfFetch.setResRowCnt_get(fetchNum);
/* 1582 */     dataOfFetch.setCurPos(curPos);
/* 1583 */     dataOfFetch.setResRowCnt_total(recvMsg.res_fetch_get_row_count());
/* 1584 */     dataOfFetch.setMsglen_total(totalLen);
/*      */     
/* 1586 */     return buf;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_commit(DmMsgSend msg)
/*      */   {
/* 1596 */     req_initMsg(msg);
/*      */     
/* 1598 */     req_setCommonHead(msg, 0, (short)8, 0);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final int resp_commit(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 1611 */     return resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_rollback(DmMsgSend msg)
/*      */   {
/* 1621 */     req_initMsg(msg);
/*      */     
/* 1623 */     req_setCommonHead(msg, 0, (short)9, 0);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final int resp_rollback(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 1636 */     return resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_close_stmt(DmMsgSend msg, int handle)
/*      */   {
/* 1648 */     req_initMsg(msg);
/*      */     
/* 1650 */     req_setCommonHead(msg, handle, (short)17, 0);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void resp_close_stmt(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 1662 */     resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_cursor_set_name(DmMsgSend msg, String serverEncoding, int handle, String cursorName)
/*      */     throws SQLException
/*      */   {
/* 1676 */     if (cursorName == null) {
/* 1677 */       DBError.throwSQLException(6036);
/*      */     }
/* 1679 */     req_initMsg(msg);
/*      */     
/* 1681 */     int len = msg.setStringWithNTS(cursorName, serverEncoding, 64);
/*      */     
/* 1683 */     msg.setInt(1);
/* 1684 */     len += 4;
/*      */     
/* 1686 */     req_setCommonHead(msg, handle, (short)27, len);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void resp_cursor_set_name(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 1699 */     resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_put_data(int handle, DmMsgSend blobMsg, int paramIndex, int len)
/*      */   {
/* 1712 */     int msgLen = 64 + len;
/*      */     
/* 1714 */     blobMsg.req_putdata_set_para_index((short)paramIndex);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1719 */     req_setCommonHead(blobMsg, handle, (short)14, msgLen - 64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void resp_put_data(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 1731 */     resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_get_data(DmMsgSend msg, int handle, int cntHasGet, DmdbLobLocator lobLocator)
/*      */   {
/* 1745 */     req_initMsg(msg);
/*      */     
/*      */ 
/* 1748 */     int offset = 64;
/*      */     
/* 1750 */     msg.setByte(lobLocator.m_lobFlag, 64);
/* 1751 */     offset++;
/*      */     
/*      */ 
/* 1754 */     msg.setBytes(lobLocator.m_tableId, 0, offset, lobLocator.m_tableId.length);
/* 1755 */     offset += lobLocator.m_tableId.length;
/*      */     
/*      */ 
/* 1758 */     msg.setBytes(lobLocator.m_colId, 0, offset, lobLocator.m_colId.length);
/* 1759 */     offset += lobLocator.m_colId.length;
/*      */     
/*      */ 
/* 1762 */     msg.setBytes(lobLocator.m_blobId, 0, offset, lobLocator.m_blobId.length);
/* 1763 */     offset += lobLocator.m_blobId.length;
/*      */     
/*      */ 
/* 1766 */     msg.setBytes(lobLocator.m_data_groupId, 0, offset, lobLocator.m_data_groupId.length);
/* 1767 */     offset += lobLocator.m_data_groupId.length;
/*      */     
/*      */ 
/* 1770 */     msg.setBytes(lobLocator.m_data_fileId, 0, offset, lobLocator.m_data_fileId.length);
/* 1771 */     offset += lobLocator.m_data_fileId.length;
/*      */     
/*      */ 
/* 1774 */     msg.setBytes(lobLocator.m_data_pageNo, 0, offset, lobLocator.m_data_pageNo.length);
/* 1775 */     offset += lobLocator.m_data_pageNo.length;
/*      */     
/*      */ 
/* 1778 */     msg.setBytes(lobLocator.m_curFileId, 0, offset, 2);
/* 1779 */     offset += lobLocator.m_curFileId.length;
/*      */     
/*      */ 
/* 1782 */     msg.setBytes(lobLocator.m_curPageNo, 0, offset, 4);
/* 1783 */     offset += lobLocator.m_curPageNo.length;
/*      */     
/*      */ 
/* 1786 */     msg.setBytes(lobLocator.m_curPageOffset, 0, offset, 2);
/* 1787 */     offset += lobLocator.m_curPageOffset.length;
/*      */     
/*      */ 
/* 1790 */     msg.setInt(lobLocator.m_blobLen - cntHasGet, offset);
/* 1791 */     offset += 4;
/*      */     
/*      */ 
/* 1794 */     req_setCommonHead(msg, handle, (short)15, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final boolean resp_get_data(DmMsgRecv recvMsg, DmdbConnection_bs conn, DmdbLobLocator locator, int hasGet)
/*      */     throws SQLException
/*      */   {
/* 1810 */     resp_checkErr(recvMsg, conn);
/*      */     
/* 1812 */     int offset = 64;
/* 1813 */     boolean isOver = recvMsg.getByte(offset) == 1;
/* 1814 */     offset++;
/*      */     
/* 1816 */     int aBlockLen = (int)recvMsg.getInt(offset);
/* 1817 */     offset += 4;
/*      */     
/* 1819 */     locator.setCurFieldId(recvMsg.getBytes(offset, 2));
/* 1820 */     offset += 2;
/*      */     
/* 1822 */     locator.setCurPageNo(recvMsg.getBytes(offset, 4));
/* 1823 */     offset += 4;
/*      */     
/* 1825 */     locator.setCurPageOffSet(recvMsg.getBytes(offset, 2));
/* 1826 */     offset += 2;
/*      */     
/* 1828 */     int copyLen = hasGet + aBlockLen > locator.m_blobLen ? locator.m_blobLen - hasGet : aBlockLen;
/*      */     
/* 1830 */     locator.m_dataOnceGet = recvMsg.getBytes(offset, copyLen);
/*      */     
/* 1832 */     return isOver;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_get_lob_len(DmMsgSend lobMsg, DmdbLobLocator lobLocator)
/*      */   {
/* 1844 */     req_initMsg(lobMsg);
/*      */     
/* 1846 */     int offset = 64;
/*      */     
/* 1848 */     lobMsg.setByte(lobLocator.m_lobFlag, offset);
/* 1849 */     offset++;
/*      */     
/*      */ 
/* 1852 */     lobMsg.setBytes(lobLocator.m_blobId, 0, offset, lobLocator.m_blobId.length);
/* 1853 */     offset += lobLocator.m_blobId.length;
/*      */     
/*      */ 
/* 1856 */     lobMsg.setBytes(lobLocator.m_data_groupId, 0, offset, lobLocator.m_data_groupId.length);
/* 1857 */     offset += lobLocator.m_data_groupId.length;
/*      */     
/*      */ 
/* 1860 */     lobMsg.setBytes(lobLocator.m_data_fileId, 0, offset, lobLocator.m_data_fileId.length);
/* 1861 */     offset += lobLocator.m_data_fileId.length;
/*      */     
/*      */ 
/* 1864 */     lobMsg.setBytes(lobLocator.m_data_pageNo, 0, offset, lobLocator.m_data_pageNo.length);
/* 1865 */     offset += lobLocator.m_data_pageNo.length;
/*      */     
/* 1867 */     if (lobLocator.m_new_lob_flag)
/*      */     {
/* 1869 */       lobMsg.setBytes(lobLocator.m_tableId, 0, offset, lobLocator.m_tableId.length);
/* 1870 */       offset += lobLocator.m_tableId.length;
/*      */       
/* 1872 */       lobMsg.setBytes(lobLocator.m_colId, 0, offset, lobLocator.m_colId.length);
/* 1873 */       offset += lobLocator.m_colId.length;
/*      */       
/* 1875 */       lobMsg.setBytes(lobLocator.m_rowId, 0, offset, lobLocator.m_rowId.length);
/* 1876 */       offset += lobLocator.m_rowId.length;
/*      */       
/* 1878 */       lobMsg.setBytes(lobLocator.m_rec_groupId, 0, offset, lobLocator.m_rec_groupId.length);
/* 1879 */       offset += lobLocator.m_rec_groupId.length;
/*      */       
/* 1881 */       lobMsg.setBytes(lobLocator.m_rec_fileId, 0, offset, lobLocator.m_rec_fileId.length);
/* 1882 */       offset += lobLocator.m_rec_fileId.length;
/*      */       
/* 1884 */       lobMsg.setBytes(lobLocator.m_rec_pageNo, 0, offset, lobLocator.m_rec_pageNo.length);
/* 1885 */       offset += lobLocator.m_rec_pageNo.length;
/*      */     }
/*      */     
/* 1888 */     req_setCommonHead(lobMsg, 0, (short)29, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final long resp_get_lob_len(DmMsgRecv recvMsg, DmdbLob lob)
/*      */     throws SQLException
/*      */   {
/* 1901 */     resp_checkErr(recvMsg, lob.getConnection());
/*      */     
/* 1903 */     return recvMsg.getInt(64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_get_lob_data(DmMsgSend blobMsg, DmdbLobLocator lobLocator, int start_pos, int length)
/*      */   {
/* 1918 */     req_initMsg(blobMsg);
/*      */     
/* 1920 */     int offset = 64;
/*      */     
/*      */ 
/* 1923 */     blobMsg.setByte(lobLocator.m_lobFlag, 64);
/* 1924 */     offset++;
/*      */     
/*      */ 
/* 1927 */     blobMsg.setBytes(lobLocator.m_tableId, 0, offset, lobLocator.m_tableId.length);
/* 1928 */     offset += lobLocator.m_tableId.length;
/*      */     
/*      */ 
/* 1931 */     blobMsg.setBytes(lobLocator.m_colId, 0, offset, lobLocator.m_colId.length);
/* 1932 */     offset += lobLocator.m_colId.length;
/*      */     
/*      */ 
/* 1935 */     blobMsg.setBytes(lobLocator.m_blobId, 0, offset, lobLocator.m_blobId.length);
/* 1936 */     offset += lobLocator.m_blobId.length;
/*      */     
/*      */ 
/* 1939 */     blobMsg.setBytes(lobLocator.m_data_groupId, 0, offset, lobLocator.m_data_groupId.length);
/* 1940 */     offset += lobLocator.m_data_groupId.length;
/*      */     
/*      */ 
/* 1943 */     blobMsg.setBytes(lobLocator.m_data_fileId, 0, offset, lobLocator.m_data_fileId.length);
/* 1944 */     offset += lobLocator.m_data_fileId.length;
/*      */     
/*      */ 
/* 1947 */     blobMsg.setBytes(lobLocator.m_data_pageNo, 0, offset, lobLocator.m_data_pageNo.length);
/* 1948 */     offset += lobLocator.m_data_pageNo.length;
/*      */     
/*      */ 
/* 1951 */     blobMsg.setBytes(lobLocator.m_curFileId, 0, offset, lobLocator.m_curFileId.length);
/* 1952 */     offset += lobLocator.m_curFileId.length;
/*      */     
/*      */ 
/* 1955 */     blobMsg.setBytes(lobLocator.m_curPageNo, 0, offset, lobLocator.m_curPageNo.length);
/* 1956 */     offset += lobLocator.m_curPageNo.length;
/*      */     
/*      */ 
/* 1959 */     blobMsg.setBytes(lobLocator.m_TotalOffset, 0, offset, lobLocator.m_TotalOffset.length);
/* 1960 */     offset += lobLocator.m_TotalOffset.length;
/*      */     
/* 1962 */     blobMsg.setInt(start_pos, offset);
/* 1963 */     offset += 4;
/*      */     
/* 1965 */     blobMsg.setInt(length, offset);
/* 1966 */     offset += 4;
/*      */     
/* 1968 */     if (lobLocator.m_new_lob_flag)
/*      */     {
/* 1970 */       blobMsg.setBytes(lobLocator.m_rowId, 0, offset, lobLocator.m_rowId.length);
/* 1971 */       offset += lobLocator.m_rowId.length;
/*      */       
/* 1973 */       blobMsg.setBytes(lobLocator.m_rec_groupId, 0, offset, lobLocator.m_rec_groupId.length);
/* 1974 */       offset += lobLocator.m_rec_groupId.length;
/*      */       
/* 1976 */       blobMsg.setBytes(lobLocator.m_rec_fileId, 0, offset, lobLocator.m_rec_fileId.length);
/* 1977 */       offset += lobLocator.m_rec_fileId.length;
/*      */       
/* 1979 */       blobMsg.setBytes(lobLocator.m_rec_pageNo, 0, offset, lobLocator.m_rec_pageNo.length);
/* 1980 */       offset += lobLocator.m_rec_pageNo.length;
/*      */     }
/*      */     
/* 1983 */     req_setCommonHead(blobMsg, 0, (short)32, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final byte[] resp_get_lob_data(DmMsgRecv recv, DmdbLobLocator lobLocator, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 1997 */     resp_checkErr(recv, conn);
/*      */     
/* 1999 */     int offset = 64;
/* 2000 */     offset++;
/*      */     
/* 2002 */     long len = recv.getInt(offset);
/* 2003 */     if (len <= 0L)
/* 2004 */       return null;
/* 2005 */     if (len > 2147483647L) {
/* 2006 */       throw new SQLException(Const.res.getString("error.valLenTLong"));
/*      */     }
/* 2008 */     offset += 4;
/*      */     
/* 2010 */     lobLocator.setCurFieldId(recv.getBytes(offset, 2));
/* 2011 */     offset += 2;
/*      */     
/* 2013 */     lobLocator.setCurPageNo(recv.getBytes(offset, 4));
/* 2014 */     offset += 4;
/*      */     
/* 2016 */     lobLocator.setTotalOffset(recv.getBytes(offset, 4));
/* 2017 */     offset += 4;
/*      */     
/* 2019 */     byte[] value = new byte[(int)len];
/* 2020 */     System.arraycopy(recv.getBuffer(), offset, value, 0, (int)len);
/* 2021 */     offset = (int)(offset + len);
/*      */     
/* 2023 */     return value;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_set_lob_data(DmMsgSend msg, DmdbLobLocator lobLocator, int start_pos, byte[] buf, int off, int len, byte firstOrLast)
/*      */   {
/* 2041 */     req_initMsg(msg);
/*      */     
/* 2043 */     int offset = 64;
/* 2044 */     msg.setByte(lobLocator.m_lobFlag, offset);
/* 2045 */     offset++;
/*      */     
/* 2047 */     msg.setByte(firstOrLast, offset);
/* 2048 */     offset++;
/*      */     
/*      */ 
/* 2051 */     msg.setBytes(lobLocator.m_blobId, 0, offset, lobLocator.m_blobId.length);
/* 2052 */     offset += lobLocator.m_blobId.length;
/*      */     
/*      */ 
/* 2055 */     msg.setBytes(lobLocator.m_data_groupId, 0, offset, lobLocator.m_data_groupId.length);
/* 2056 */     offset += lobLocator.m_data_groupId.length;
/*      */     
/*      */ 
/* 2059 */     msg.setBytes(lobLocator.m_data_fileId, 0, offset, lobLocator.m_data_fileId.length);
/* 2060 */     offset += lobLocator.m_data_fileId.length;
/*      */     
/*      */ 
/* 2063 */     msg.setBytes(lobLocator.m_data_pageNo, 0, offset, lobLocator.m_data_pageNo.length);
/* 2064 */     offset += lobLocator.m_data_pageNo.length;
/*      */     
/*      */ 
/* 2067 */     msg.setBytes(lobLocator.m_curFileId, 0, offset, 2);
/* 2068 */     offset += 2;
/*      */     
/*      */ 
/* 2071 */     msg.setBytes(lobLocator.m_curPageNo, 0, offset, 4);
/* 2072 */     offset += 4;
/*      */     
/*      */ 
/* 2075 */     msg.setBytes(lobLocator.m_TotalOffset, 0, offset, lobLocator.m_TotalOffset.length);
/* 2076 */     offset += lobLocator.m_TotalOffset.length;
/*      */     
/*      */ 
/* 2079 */     msg.setBytes(lobLocator.m_tableId, 0, offset, lobLocator.m_tableId.length);
/* 2080 */     offset += lobLocator.m_tableId.length;
/*      */     
/*      */ 
/* 2083 */     msg.setBytes(lobLocator.m_colId, 0, offset, lobLocator.m_colId.length);
/* 2084 */     offset += lobLocator.m_colId.length;
/*      */     
/* 2086 */     msg.setBytes(lobLocator.m_rowId, 0, offset, lobLocator.m_rowId.length);
/* 2087 */     offset += lobLocator.m_rowId.length;
/*      */     
/* 2089 */     msg.setInt(start_pos, offset);
/* 2090 */     offset += 4;
/*      */     
/* 2092 */     msg.setInt(len, offset);
/* 2093 */     offset += 4;
/*      */     
/* 2095 */     msg.setBytes(buf, off, offset, len);
/* 2096 */     offset += len;
/*      */     
/* 2098 */     if (lobLocator.m_new_lob_flag)
/*      */     {
/* 2100 */       msg.setBytes(lobLocator.m_rec_groupId, 0, offset, lobLocator.m_rec_groupId.length);
/* 2101 */       offset += lobLocator.m_rec_groupId.length;
/*      */       
/* 2103 */       msg.setBytes(lobLocator.m_rec_fileId, 0, offset, lobLocator.m_rec_fileId.length);
/* 2104 */       offset += lobLocator.m_rec_fileId.length;
/*      */       
/* 2106 */       msg.setBytes(lobLocator.m_rec_pageNo, 0, offset, lobLocator.m_rec_pageNo.length);
/* 2107 */       offset += lobLocator.m_rec_pageNo.length;
/*      */     }
/*      */     
/* 2110 */     req_setCommonHead(msg, 0, (short)30, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final int resp_set_lob_data(DmMsgRecv recv, DmdbLobLocator lobLocator, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 2130 */     resp_checkErr(recv, conn);
/*      */     
/* 2132 */     int offset = 64;
/*      */     
/* 2134 */     int ret = (int)recv.getInt(offset);
/* 2135 */     offset += 4;
/*      */     
/* 2137 */     lobLocator.setBlobId(recv.getBytes(offset, 8));
/* 2138 */     offset += 8;
/*      */     
/* 2140 */     lobLocator.setGroupId(recv.getBytes(offset, 2));
/* 2141 */     offset += 2;
/*      */     
/* 2143 */     lobLocator.setFileId(recv.getBytes(offset, 2));
/* 2144 */     offset += 2;
/*      */     
/* 2146 */     lobLocator.setPageNo(recv.getBytes(offset, 4));
/* 2147 */     offset += 4;
/*      */     
/* 2149 */     lobLocator.setCurFieldId(recv.getBytes(offset, 2));
/* 2150 */     offset += 2;
/*      */     
/* 2152 */     lobLocator.setCurPageNo(recv.getBytes(offset, 4));
/* 2153 */     offset += 4;
/*      */     
/* 2155 */     lobLocator.setTotalOffset(recv.getBytes(offset, 4));
/* 2156 */     offset += 4;
/*      */     
/* 2158 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_lob_truncate(DmMsgSend msg, DmdbLobLocator lobLocator, int length)
/*      */   {
/* 2171 */     req_initMsg(msg);
/*      */     
/* 2173 */     int offset = 64;
/*      */     
/* 2175 */     msg.setByte(lobLocator.m_lobFlag, offset);
/* 2176 */     offset++;
/*      */     
/*      */ 
/* 2179 */     msg.setBytes(lobLocator.m_blobId, 0, offset, lobLocator.m_blobId.length);
/* 2180 */     offset += lobLocator.m_blobId.length;
/*      */     
/*      */ 
/* 2183 */     msg.setBytes(lobLocator.m_data_groupId, 0, offset, lobLocator.m_data_groupId.length);
/* 2184 */     offset += lobLocator.m_data_groupId.length;
/*      */     
/*      */ 
/* 2187 */     msg.setBytes(lobLocator.m_data_fileId, 0, offset, lobLocator.m_data_fileId.length);
/* 2188 */     offset += lobLocator.m_data_fileId.length;
/*      */     
/*      */ 
/* 2191 */     msg.setBytes(lobLocator.m_data_pageNo, 0, offset, lobLocator.m_data_pageNo.length);
/* 2192 */     offset += lobLocator.m_data_pageNo.length;
/*      */     
/*      */ 
/* 2195 */     msg.setBytes(lobLocator.m_tableId, 0, offset, lobLocator.m_tableId.length);
/* 2196 */     offset += lobLocator.m_tableId.length;
/*      */     
/*      */ 
/* 2199 */     msg.setBytes(lobLocator.m_colId, 0, offset, lobLocator.m_colId.length);
/* 2200 */     offset += lobLocator.m_colId.length;
/*      */     
/* 2202 */     msg.setBytes(lobLocator.m_rowId, 0, offset, lobLocator.m_rowId.length);
/* 2203 */     offset += lobLocator.m_rowId.length;
/*      */     
/* 2205 */     msg.setInt(length, offset);
/* 2206 */     offset += 4;
/*      */     
/* 2208 */     if (lobLocator.m_new_lob_flag)
/*      */     {
/* 2210 */       msg.setBytes(lobLocator.m_rec_groupId, 0, offset, lobLocator.m_rec_groupId.length);
/* 2211 */       offset += lobLocator.m_rec_groupId.length;
/*      */       
/* 2213 */       msg.setBytes(lobLocator.m_rec_fileId, 0, offset, lobLocator.m_rec_fileId.length);
/* 2214 */       offset += lobLocator.m_rec_fileId.length;
/*      */       
/* 2216 */       msg.setBytes(lobLocator.m_rec_pageNo, 0, offset, lobLocator.m_rec_pageNo.length);
/* 2217 */       offset += lobLocator.m_rec_pageNo.length;
/*      */     }
/*      */     
/* 2220 */     req_setCommonHead(msg, 0, (short)31, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final long resp_lob_truncate(DmMsgRecv recv, DmdbLobLocator lobLocator, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 2235 */     resp_checkErr(recv, conn);
/*      */     
/* 2237 */     int offset = 64;
/*      */     
/* 2239 */     long ret = recv.getInt(offset);
/* 2240 */     offset += 4;
/*      */     
/* 2242 */     lobLocator.setBlobId(recv.getBytes(offset, 8));
/* 2243 */     offset += 8;
/*      */     
/* 2245 */     lobLocator.setCurToHead();
/*      */     
/* 2247 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_more_result(DmMsgSend msg, int handle, short resId)
/*      */   {
/* 2261 */     req_initMsg(msg);
/*      */     
/* 2263 */     msg.req_moreres_set_res_id(resId);
/*      */     
/* 2265 */     req_setCommonHead(msg, handle, (short)44, 0);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void req_sess_iso(DmMsgSend msg, int isoLevel)
/*      */   {
/* 2276 */     req_initMsg(msg);
/*      */     
/* 2278 */     msg.req_sess_iso_set_level(isoLevel);
/*      */     
/* 2280 */     req_setCommonHead(msg, 0, (short)52, 0);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static final void resp_sess_iso(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 2292 */     resp_checkErr(recvMsg, conn);
/*      */   }
/*      */   
/*      */   public static final short resp_svr_mode(DmMsgRecv recvMsg)
/*      */   {
/* 2297 */     return (short)recvMsg.getShort(14);
/*      */   }
/*      */   
/*      */   public static final short resp_ret_type(DmMsgRecv recvMsg)
/*      */   {
/* 2302 */     return (short)recvMsg.getShort(4);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */   private static void req_initMsg(DmMsgSend msg)
/*      */   {
/* 2309 */     msg.resetCurNode();
/*      */   }
/*      */   
/*      */   private static void req_setCommonHead(DmMsgSend msg, int handle, short command, int msglen)
/*      */   {
/* 2314 */     msg.req_set_cmd(command);
/*      */     
/* 2316 */     msg.req_set_len(msglen);
/*      */     
/* 2318 */     msg.req_set_stmtid(handle);
/*      */   }
/*      */   
/*      */ 
/*      */   private static void resp_startup_get_msghead(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */   {
/* 2324 */     conn.setEncryptMsg(recvMsg.res_startup_get_encrypt_type());
/*      */     
/*      */ 
/* 2327 */     conn.setGlobalServerSeries(recvMsg.res_startup_get_serial());
/*      */     
/*      */ 
/* 2330 */     if (1 == recvMsg.res_startup_get_ucflag()) {
/* 2331 */       conn.setServerEncoding("UTF-8");
/* 2332 */     } else if (2 == recvMsg.res_startup_get_ucflag()) {
/* 2333 */       conn.setServerEncoding("EUC-KR");
/*      */     } else {
/* 2335 */       conn.setServerEncoding("GB18030");
/*      */     }
/*      */     
/* 2338 */     conn.setComprMsg(recvMsg.res_startup_get_cmpflag());
/*      */     
/* 2340 */     if (recvMsg.res_startup_get_rs_bdta_flag() == 0) {
/* 2341 */       conn.setIsBdta(false);
/*      */     } else {
/* 2343 */       conn.setIsBdta(true);
/*      */     }
/*      */   }
/*      */   
/*      */   private static void resp_dbVersionCheck(String verFrmSvr, int len) throws SQLException
/*      */   {
/* 2349 */     long valFromSvr = 0L;
/* 2350 */     long valLocal = 0L;
/* 2351 */     String str = "";
/* 2352 */     String tmpStr = "";
/* 2353 */     for (int i = 0; i < len; i++)
/*      */     {
/* 2355 */       if (verFrmSvr.charAt(i) == '.')
/*      */       {
/* 2357 */         if (tmpStr.length() == 1)
/*      */         {
/* 2359 */           tmpStr = "0" + tmpStr;
/*      */         }
/* 2361 */         str = str + tmpStr;
/* 2362 */         tmpStr = "";
/*      */       }
/*      */       else {
/* 2365 */         tmpStr = tmpStr + verFrmSvr.charAt(i);
/*      */       } }
/* 2367 */     if (tmpStr.length() == 1)
/*      */     {
/* 2369 */       tmpStr = "0" + tmpStr;
/*      */     }
/* 2371 */     str = str + tmpStr;
/*      */     
/* 2373 */     valFromSvr = new Long(str).longValue();
/*      */     
/* 2375 */     str = "";
/* 2376 */     tmpStr = "";
/*      */     
/* 2378 */     String dbVerLocal = DmdbType.getDbProductVer();
/* 2379 */     len = dbVerLocal.length();
/* 2380 */     for (i = 0; i < len; i++)
/*      */     {
/* 2382 */       if (dbVerLocal.charAt(i) == '.')
/*      */       {
/* 2384 */         if (tmpStr.length() == 1)
/*      */         {
/* 2386 */           tmpStr = "0" + tmpStr;
/*      */         }
/* 2388 */         str = str + tmpStr;
/* 2389 */         tmpStr = "";
/*      */       }
/*      */       else {
/* 2392 */         tmpStr = tmpStr + dbVerLocal.charAt(i);
/*      */       } }
/* 2394 */     if (tmpStr.length() == 1)
/*      */     {
/* 2396 */       tmpStr = "0" + tmpStr;
/*      */     }
/* 2398 */     str = str + tmpStr;
/*      */     
/* 2400 */     valLocal = new Long(str).longValue();
/*      */     
/* 2402 */     if (valFromSvr < valLocal)
/*      */     {
/* 2404 */       DBError.throwSQLException(Const.res.getString("error.version.server"));
/*      */     }
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private static int resp_checkErr(DmMsgRecv recvMsg, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 2424 */     String serverEncoding = conn.getServerEncoding();
/* 2425 */     if (!StringUtil.isEmpty(serverEncoding))
/*      */     {
/* 2427 */       if ((conn.getLanguage() == 0) && 
/* 2428 */         (serverEncoding.equalsIgnoreCase("EUC-KR")))
/*      */       {
/* 2430 */         serverEncoding = "GB18030";
/*      */       }
/*      */     }
/*      */     
/* 2434 */     int sqlcode = recvMsg.res_get_sqlcode();
/*      */     
/* 2436 */     if (sqlcode < 0)
/*      */     {
/* 2438 */       if (sqlcode == 58500) {
/* 2439 */         return sqlcode;
/*      */       }
/* 2441 */       String errInfo = recvMsg.getErrorInfo(serverEncoding);
/*      */       
/* 2443 */       if (conn.checkHasStandby())
/*      */       {
/* 2445 */         if (recvMsg.getFromStandby())
/*      */         {
/* 2447 */           errInfo = "[S] " + errInfo == null ? "" : errInfo;
/*      */         }
/*      */         else
/*      */         {
/* 2451 */           errInfo = "[P] " + errInfo == null ? "" : errInfo;
/*      */         }
/*      */       }
/* 2454 */       DBError.throwSQLException(errInfo, sqlcode);
/*      */     }
/*      */     
/* 2457 */     if (sqlcode == 117)
/*      */     {
/* 2459 */       SQLWarning warning = new SQLWarning(Const.res.getString("warning.rangeWarn"));
/* 2460 */       conn.addWarnings(warning);
/*      */     }
/* 2462 */     if (sqlcode == 119)
/*      */     {
/* 2464 */       SQLWarning warning = new SQLWarning(Const.res.getString("warning.listWarn"));
/* 2465 */       conn.addWarnings(warning);
/*      */     }
/* 2467 */     if (sqlcode == 202)
/*      */     {
/* 2469 */       long explain_len = recvMsg.getInt(64);
/*      */       
/* 2471 */       if (explain_len > 2147483647L) {
/* 2472 */         explain_len = 2147483647L;
/*      */       }
/* 2474 */       String pln = recvMsg.getString(68, (int)explain_len, 
/* 2475 */         serverEncoding);
/*      */       
/* 2477 */       DBError.throwSQLException(pln, sqlcode);
/*      */     }
/* 2479 */     if (sqlcode == 121)
/*      */     {
/* 2481 */       SQLWarning warning = new SQLWarning(Const.res.getString("warn.bp_with_err"));
/* 2482 */       conn.addWarnings(warning);
/*      */     }
/*      */     
/* 2485 */     return sqlcode;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private static final int resp_getParaDesc(DmMsgRecv recv, int offset, int paraNum, DmdbInfo des, DmdbStatement_bs stmt)
/*      */     throws SQLException
/*      */   {
/* 2505 */     if (paraNum > 0)
/*      */     {
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 2512 */       boolean isLob = false;
/* 2513 */       ParameterDesc[] paramsInfo = new ParameterDesc[paraNum];
/* 2514 */       DmdbConnection_bs conn = stmt.getConnection_bs();
/*      */       
/* 2516 */       for (int i = 0; i < paraNum; i++)
/*      */       {
/* 2518 */         paramsInfo[i] = new ParameterDesc();
/*      */         
/* 2520 */         int dataType = (int)recv.getInt(offset);
/* 2521 */         offset += 4;
/*      */         
/*      */ 
/* 2524 */         int typePrec = (int)recv.getInt(offset);
/* 2525 */         offset += 4;
/* 2526 */         int typeScale = (int)recv.getInt(offset);
/* 2527 */         offset += 4;
/*      */         
/* 2529 */         if ((dataType == 54) && (typePrec == 0)) {
/* 2530 */           paramsInfo[i].setPrec(8188);
/* 2531 */         } else if ((dataType == 12) || (dataType == 19)) {
/* 2532 */           paramsInfo[i].setPrec(Integer.MAX_VALUE);
/*      */         } else {
/* 2534 */           paramsInfo[i].setPrec(typePrec);
/*      */         }
/* 2536 */         paramsInfo[i].setScale(typeScale);
/*      */         
/*      */ 
/* 2539 */         boolean nullable = recv.getInt(offset) != 0L;
/* 2540 */         offset += 4;
/*      */         
/* 2542 */         short itemFlag = (short)recv.getShort(offset);
/* 2543 */         offset += 2;
/*      */         
/*      */ 
/* 2546 */         if ((itemFlag & 0x2) == 2)
/*      */         {
/* 2548 */           paramsInfo[i].setIsLob(true);
/* 2549 */           isLob = true;
/*      */         }
/*      */         else
/*      */         {
/* 2553 */           isLob = false;
/*      */         }
/*      */         
/* 2556 */         byte typeFlag = (itemFlag & 0x8) != 0 ? 2 : 
/* 2557 */           1;
/*      */         
/* 2559 */         if (dataType == 54) {
/* 2560 */           typeFlag = 0;
/*      */         }
/*      */         
/* 2563 */         offset += 4;
/*      */         
/* 2565 */         short ioType = (short)recv.getShort(offset);
/* 2566 */         offset += 2;
/*      */         
/* 2568 */         short nameLen = (short)recv.getShort(offset);
/* 2569 */         offset += 2;
/*      */         
/* 2571 */         short typeNameLen = (short)recv.getShort(offset);
/* 2572 */         offset += 2;
/*      */         
/* 2574 */         short tableLen = (short)recv.getShort(offset);
/* 2575 */         offset += 2;
/*      */         
/* 2577 */         short schemaLen = (short)recv.getShort(offset);
/* 2578 */         offset += 2;
/*      */         
/*      */         try
/*      */         {
/* 2582 */           String serverEncoding = conn.getServerEncoding();
/* 2583 */           String tempName = recv.getString(offset, nameLen, serverEncoding);
/* 2584 */           paramsInfo[i].setName(tempName);
/* 2585 */           offset += nameLen;
/*      */           
/* 2587 */           tempName = recv.getString(offset, typeNameLen, serverEncoding);
/* 2588 */           paramsInfo[i].setTypeName(tempName);
/* 2589 */           offset += typeNameLen;
/*      */           
/* 2591 */           tempName = recv.getString(offset, tableLen, serverEncoding);
/* 2592 */           paramsInfo[i].setTabName(tempName);
/* 2593 */           offset += tableLen;
/*      */           
/* 2595 */           tempName = recv.getString(offset, schemaLen, serverEncoding);
/* 2596 */           paramsInfo[i].setSchName(tempName);
/* 2597 */           offset += schemaLen;
/*      */ 
/*      */         }
/*      */         catch (Exception ex)
/*      */         {
/* 2602 */           System.out.println(ex.toString());
/*      */         }
/*      */         
/* 2605 */         paramsInfo[i].setDType(dataType);
/* 2606 */         paramsInfo[i].setNullable(nullable);
/* 2607 */         paramsInfo[i].setTypeFlag(typeFlag);
/* 2608 */         paramsInfo[i].setIOType((byte)ioType);
/*      */         
/* 2610 */         if (isLob)
/*      */         {
/* 2612 */           paramsInfo[i].setTabId((int)recv.getInt(offset));
/* 2613 */           offset += 4;
/* 2614 */           paramsInfo[i].setColId((short)recv.getShort(offset));
/* 2615 */           offset += 2;
/*      */         }
/*      */       }
/*      */       
/*      */ 
/* 2620 */       for (int i = 0; i < paraNum; i++)
/*      */       {
/* 2622 */         int dataType = paramsInfo[i].getDType();
/*      */         
/* 2624 */         if ((dataType == 117) || (dataType == 122) || 
/* 2625 */           (dataType == 119) || (dataType == 120) || 
/* 2626 */           (dataType == 121))
/*      */         {
/* 2628 */           TypeDescriptor typeDesc = new TypeDescriptor(conn);
/* 2629 */           offset = typeDesc.unpack(recv.getBuffer(), offset);
/* 2630 */           paramsInfo[i].setTypeDescriptor(typeDesc);
/*      */         }
/*      */       }
/*      */       
/*      */ 
/* 2635 */       des.setParamsInfo(paramsInfo);
/*      */     }
/*      */     
/* 2638 */     return offset;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private static final int resp_getColDesc(DmMsgRecv recv, int offset, int colNum, DmdbInfo des, DmdbStatement_bs stmt)
/*      */     throws SQLException
/*      */   {
/* 2659 */     if (colNum > 0)
/*      */     {
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 2665 */       boolean isLob = false;
/*      */       
/* 2667 */       DmdbColumn[] columnsInfo = new DmdbColumn[colNum];
/* 2668 */       DmdbConnection_bs conn = stmt.getConnection_bs();
/*      */       
/* 2670 */       for (int i = 0; i < colNum; i++)
/*      */       {
/* 2672 */         columnsInfo[i] = new DmdbColumn(conn);
/* 2673 */         columnsInfo[i].getDesc().setLobMode(conn.getLobMode());
/*      */         
/* 2675 */         int dataType = recv.getdType(offset);
/* 2676 */         int typePrec = recv.getPrec(offset);
/* 2677 */         int typeScale = recv.getScale(offset);
/* 2678 */         boolean nullable = recv.getNullable(offset);
/* 2679 */         short itemFlag = recv.getItemFlag(offset);
/* 2680 */         short nameLen = recv.getNameLen(offset);
/* 2681 */         short typeNameLen = recv.getTypeNameLen(offset);
/* 2682 */         short tableLen = recv.getTableLen(offset);
/* 2683 */         short schemaLen = recv.getSchemaLen(offset);
/* 2684 */         offset += 32;
/*      */         
/*      */ 
/* 2687 */         if ((itemFlag & 0x1) == 1) {
/* 2688 */           columnsInfo[i].getDesc().setIdentity(true);
/*      */         }
/*      */         
/* 2691 */         if ((itemFlag & 0x2) == 2)
/*      */         {
/* 2693 */           columnsInfo[i].getDesc().setIsLob(true);
/* 2694 */           isLob = true;
/*      */         }
/*      */         else
/*      */         {
/* 2698 */           isLob = false;
/*      */         }
/*      */         
/*      */ 
/* 2702 */         if ((itemFlag & 0x4) == 4)
/*      */         {
/* 2704 */           columnsInfo[i].getDesc().setReadOnly(true);
/*      */         }
/*      */         else
/*      */         {
/* 2708 */           columnsInfo[i].getDesc().setReadOnly(false);
/*      */         }
/*      */         
/* 2711 */         String serverEncoding = conn.getServerEncoding();
/* 2712 */         String tempName = recv.getString(offset, nameLen, serverEncoding);
/* 2713 */         columnsInfo[i].getDesc().setName(tempName);
/* 2714 */         offset += nameLen;
/*      */         
/* 2716 */         tempName = recv.getString(offset, typeNameLen, serverEncoding);
/* 2717 */         columnsInfo[i].getDesc().setTypeName(tempName);
/* 2718 */         offset += typeNameLen;
/*      */         
/* 2720 */         tempName = recv.getString(offset, tableLen, serverEncoding);
/* 2721 */         columnsInfo[i].getDesc().setTabName(tempName);
/* 2722 */         offset += tableLen;
/*      */         
/* 2724 */         tempName = recv.getString(offset, schemaLen, serverEncoding);
/* 2725 */         columnsInfo[i].getDesc().setSchName(tempName);
/* 2726 */         offset += schemaLen;
/*      */         
/* 2728 */         columnsInfo[i].getDesc().setDType(dataType);
/* 2729 */         columnsInfo[i].getDesc().setPrec(typePrec);
/* 2730 */         columnsInfo[i].getDesc().setScale(typeScale);
/* 2731 */         columnsInfo[i].getDesc().setNullable(nullable);
/*      */         
/* 2733 */         if (stmt.isReadBaseColName())
/*      */         {
/* 2735 */           int baseNameLen = recv.getShort(offset);
/* 2736 */           offset += 2;
/*      */           
/* 2738 */           if (baseNameLen > 0)
/*      */           {
/* 2740 */             String baseName = recv.getString(offset, baseNameLen, serverEncoding);
/* 2741 */             columnsInfo[i].getDesc().setBaseName(baseName);
/* 2742 */             offset += baseNameLen;
/*      */           }
/*      */         }
/*      */         
/* 2746 */         if (isLob)
/*      */         {
/* 2748 */           columnsInfo[i].getDesc().setTabId((int)recv.getInt(offset));
/* 2749 */           offset += 4;
/* 2750 */           columnsInfo[i].getDesc().setColId((short)recv.getShort(offset));
/* 2751 */           offset += 2;
/*      */         }
/*      */       }
/*      */       
/*      */ 
/* 2756 */       for (int i = 0; i < colNum; i++) {
/* 2757 */         offset = columnsInfo[i].checkComplexType(recv.getBuffer(), offset);
/*      */       }
/* 2759 */       des.setColumnsInfo(columnsInfo);
/* 2760 */       des.setHasResultSet(true);
/*      */     }
/*      */     
/* 2763 */     return offset;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private static final void resp_getResultSetData(DmdbStatement_bs stmt, DmMsgRecv msg, long rowNum, DmdbColumn[] colsInfo, int offset, int rsCacheOffset, int rowidCol, boolean isBdtaRs)
/*      */     throws SQLException
/*      */   {
/* 2780 */     int fetched_rows = msg.res_execute_get_fetched_rows();
/* 2781 */     if (fetched_rows > 0)
/*      */     {
/* 2783 */       if (isBdtaRs)
/*      */       {
/* 2785 */         stmt.setRsCache(new DmdbResultSetCache_v(stmt, colsInfo, rowidCol));
/*      */       }
/*      */       else
/*      */       {
/* 2789 */         stmt.setRsCache(new DmdbResultSetCache_h(stmt, colsInfo)); }
/*      */       long len;
/*      */       long len;
/* 2792 */       if (rsCacheOffset == 0)
/*      */       {
/* 2794 */         long msgLen = msg.res_get_len();
/* 2795 */         len = msgLen + 64L - offset;
/*      */       }
/*      */       else {
/* 2798 */         len = rsCacheOffset - offset;
/*      */       }
/* 2800 */       stmt.getRsCache().fillBuffer2(msg.getBuffer(), offset, (int)len, fetched_rows);
/*      */     }
/*      */     
/* 2803 */     if (rsCacheOffset == 0) {
/* 2804 */       return;
/*      */     }
/* 2806 */     int tbCount = msg.getShort(rsCacheOffset);
/* 2807 */     rsCacheOffset += 2;
/*      */     
/* 2809 */     long[] ids = new long[tbCount];
/* 2810 */     long[] tss = new long[tbCount];
/*      */     
/* 2812 */     for (int i = 0; i < tbCount; i++)
/*      */     {
/* 2814 */       ids[i] = msg.getInt(rsCacheOffset);
/* 2815 */       rsCacheOffset += 4;
/*      */       
/* 2817 */       tss[i] = msg.getLong(rsCacheOffset);
/* 2818 */       rsCacheOffset += 8;
/*      */     }
/*      */     
/* 2821 */     stmt.setTbsId_Ts(ids, tss);
/* 2822 */     ids = null;
/* 2823 */     tss = null;
/*      */   }
/*      */   
/*      */   private static int resp_getDatatype(ParameterDesc paramDesc)
/*      */   {
/* 2828 */     if (paramDesc.getTypeFlag() == 1) {
/* 2829 */       return paramDesc.getDType();
/*      */     }
/* 2831 */     return paramDesc.getRecommendDType();
/*      */   }
/*      */   
/*      */   private static int resp_getDataPrec(ParameterDesc paramDesc)
/*      */   {
/* 2836 */     if (paramDesc.getTypeFlag() == 1) {
/* 2837 */       return paramDesc.getPrec();
/*      */     }
/* 2839 */     return paramDesc.getRecommendPrec();
/*      */   }
/*      */   
/*      */   private static int resp_getDataScale(ParameterDesc paramDesc)
/*      */   {
/* 2844 */     if (paramDesc.getTypeFlag() == 1) {
/* 2845 */       return paramDesc.getScale();
/*      */     }
/* 2847 */     return paramDesc.getRecommendScale();
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static void req_table_ts(DmMsgSend msg, long[] tbIds)
/*      */   {
/* 2858 */     req_initMsg(msg);
/*      */     
/* 2860 */     int tbCount = tbIds.length;
/* 2861 */     msg.setShort(tbCount, 20);
/*      */     
/* 2863 */     int offset = 64;
/* 2864 */     for (int i = 0; i < tbCount; i++)
/*      */     {
/* 2866 */       msg.setInt((int)tbIds[i], offset);
/* 2867 */       offset += 4;
/*      */     }
/*      */     
/* 2870 */     req_setCommonHead(msg, 0, (short)71, offset - 64);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static long[] resp_table_ts(DmMsgRecv recv, DmdbConnection_bs conn)
/*      */     throws SQLException
/*      */   {
/* 2882 */     resp_checkErr(recv, conn);
/*      */     
/* 2884 */     int tbCount = recv.getShort(20);
/* 2885 */     if (tbCount <= 0) {
/* 2886 */       return null;
/*      */     }
/* 2888 */     long[] tss = new long[tbCount];
/* 2889 */     int offset = 64;
/* 2890 */     for (int i = 0; i < tbCount; i++)
/*      */     {
/* 2892 */       tss[i] = recv.getLong(offset);
/* 2893 */       offset += 8;
/*      */     }
/*      */     
/* 2896 */     return tss;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static void req_xa_common(DmMsgSend msg, int xa_type, Xid xid, int flag)
/*      */   {
/* 2908 */     req_initMsg(msg);
/*      */     
/*      */ 
/* 2911 */     msg.req_xa_set_xa_type(xa_type);
/*      */     
/*      */ 
/* 2914 */     if (xid != null)
/*      */     {
/* 2916 */       byte[] xid_tmp = new byte[''];
/* 2917 */       byte[] gtId = xid.getGlobalTransactionId();
/* 2918 */       System.arraycopy(gtId, 0, xid_tmp, 0, gtId.length);
/* 2919 */       byte[] bq = xid.getBranchQualifier();
/* 2920 */       System.arraycopy(bq, 0, xid_tmp, 64, bq.length);
/*      */       
/* 2922 */       msg.req_xa_set_xid(xid.getFormatId(), gtId.length, bq.length, xid_tmp);
/*      */     }
/*      */     
/*      */ 
/* 2926 */     msg.req_xa_set_xa_flag(flag);
/*      */     
/* 2928 */     req_setCommonHead(msg, 0, (short)60, 148);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static int resp_xa_common(DmMsgRecv recvMsg)
/*      */     throws SQLException, XAException
/*      */   {
/* 2942 */     int sqlcode = recvMsg.res_get_xa_sqlcode();
/*      */     
/* 2944 */     if (sqlcode != 0)
/*      */     {
/*      */ 
/* 2947 */       throw new DmdbXAException(sqlcode);
/*      */     }
/*      */     
/* 2950 */     if (sqlcode == 3) {
/* 2951 */       return 3;
/*      */     }
/* 2953 */     return sqlcode;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public static DmdbXid[] resp_xa_recover(DmdbXAResource xaResource, DmMsgRecv recvMsg)
/*      */     throws XAException
/*      */   {
/* 2966 */     recvMsg.res_get_xa_sqlcode();
/*      */     
/* 2968 */     int endflag = recvMsg.res_get_xa_recovery_endflag();
/* 2969 */     int xid_count = recvMsg.res_get_xa_recovery_xid_count();
/*      */     
/* 2971 */     if (endflag == 1) {
/* 2972 */       xaResource.setRecoverd(true);
/*      */     } else {
/* 2974 */       xaResource.setRecoverd(false);
/*      */     }
/* 2976 */     if (xid_count > 0)
/*      */     {
/* 2978 */       DmdbXid[] xids = new DmdbXid[xid_count];
/* 2979 */       for (int i = 0; i < xid_count; i++)
/*      */       {
/* 2981 */         xids[i] = recvMsg.res_get_xa_recovery_xid(i);
/*      */       }
/* 2983 */       return xids;
/*      */     }
/*      */     
/* 2986 */     return null;
/*      */   }
/*      */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\dbaccess\Request_Response.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */